Display Pg buffer cache (WIP)

From: Mark Kirkwood <markir(at)coretech(dot)co(dot)nz>
To: pgsql-patches(at)postgresql(dot)org
Subject: Display Pg buffer cache (WIP)
Date: 2005-03-03 05:36:04
Message-ID: 4226A244.7000100@coretech.co.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

I found it useful to be able to look at what relations are occupying the
cache (mainly for debugging and comparing with page estimates).

I am wondering if it might be a useful addition generally?

How it works a SRF called dump_cache() is created, which is then exposed
as system view pg_dump_cache. So stuff like the following can be
performed (cache of 2000 immediately after 'make installcheck'):

regression=# SELECT c.relname, count(*) AS buffers
regression-# FROM pg_class c, pg_dump_cache d
regression-# WHERE d.relfilenode = c.relfilenode
regression-# GROUP BY c.relname
regression-# ORDER BY 2 DESC LIMIT 10;

relname | buffers
---------------------------------+---------
tenk1 | 345
tenk2 | 345
onek | 138
pg_attribute | 102
road | 81
pg_attribute_relid_attnam_index | 74
onek2 | 69
pg_proc | 59
pg_proc_proname_args_nsp_index | 56
hash_f8_heap | 49
(10 rows)

regression=#

As of now the patch breaks 1 regression test (rules - that new view...)
and does not peek into the contents of the buffers themselves (I was
mainly interested in which relations were there), and does not worry too
much about a consistent view of the buffer contents (as I didn't want it
to block all other activity!).

If it seems like a worthwhile addition I will amend the regression
expected and resubmit.

Any comments?

Mark

Attachment Content-Type Size
pgsql-8.1devel-dumpcache.patch text/plain 5.1 KB

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Neil Conway 2005-03-03 07:15:25 Re: Display Pg buffer cache (WIP)
Previous Message Bruce Momjian 2005-03-03 05:20:35 Re: [HACKERS] UTF8 or Unicode