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: dumpcache.tar.gz
Description: application/macbinary

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Reply via email to