dump cache summary

From: Mark Kirkwood <markir(at)paradise(dot)net(dot)nz>
To: pgsql-hackers(at)postgresql(dot)org
Subject: dump cache summary
Date: 2003-09-08 09:22:32
Message-ID: 3F5C4A58.3070709@paradise.net.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

As part of attempting to gain an understanding of how Postgres works, I
wanted to see if I could display a summary of what relations were using
pages in the cache.

Having done that, I was all set to trash the code when I wondered if it
might be useful in its own right...

Here is a sample of the output after a pgbench run with shared_buffers=500:

bench=>dumpcache;
CACHE DUMP
-----------------------------------------------------------------
pg_type_oid_index 2
pg_proc 1
history 3
pg_class_relname_nsp_index 5
pg_statistic_relid_att_index 2
tellers_pkey 9
<invalid oid> 4
accounts 205
pg_am 1
pg_statistic 1
branches 2
accounts_pkey 215
pg_amproc_opc_procnum_index 2
branches_pkey 9
pg_operator_oid_index 3
tellers 4
pg_class_oid_index 2
pg_type 2
pg_index_indexrelid_index 2
pg_trigger_tgrelid_tgname_index 2
pg_amop_opr_opc_index 2
pg_index_indrelid_index 2
pg_class 2
pg_trigger 1
pg_proc_oid_index 1
pg_amop_opc_strategy_index 2
pg_attribute_relid_attnum_index 4
pg_amop 1
pg_amproc 1
pg_index 2
pg_operator 3
pg_attribute 3
(32 rows)

bench=>

Does this seem like a useful thing to be able to display ?

I implemented this by adding a command (as I wanted to know how this was
done), but I suspect it would make more sense to use a function a bit
like the pg_stat* collection.

I have included (most of) the code I used, so that interested parties
can show me what I have done wrong :-)

(Some things I wondered about were : should I be locking buffers before
peeking at the corresponding descriptors?, does it make sense to call
RelationIdGetRelation on a relNode?.... )

regards

Mark

Attachment Content-Type Size
dumpcache.tar.gz application/x-macbinary 2.0 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Conrad Vermeulen 2003-09-08 09:27:30 FW: indirect dereferencing a field in a record using plpgsql
Previous Message andrew 2003-09-08 06:32:17 Re: ISO 8601 'Time Intervals' of the 'format with time-unit deignators'