Creating a new block in a database
Once you insert something into this table, a page is allocated in the buffer cache to hold that new information, and a standard 8 K block is allocated on disk:
$ psql -c "INSERT into t(i) values (0)" INSERT 0 1 $ ls -l $PGDATA/base/11880/16391* -rw------- 1 postgres postgres 8192 2010-03-01 21:03 /home/postgres/pgwork/data/base/11880/16391 $ psql -c "SELECT reldatabase,relfilenode,relblocknumber,isdirty,usagecount FROM pg_buffercache WHERE relfilenode=16391;" reldatabase | relfilenode | relblocknumber | isdirty | usagecount -------------+-------------+----------------+---------+------------ 11880 | 16391 | 0 | t | 1
Note that this block is dirty. That means that the version in memory has not been written out to disk yet. Also note that the usagecount
for it is 1. This means that one database process has accessed this block since its section of the buffer cache was last considered as a...