contrib/pg_stat_statements 1202 - Mailing list pgsql-hackers

From ITAGAKI Takahiro
Subject contrib/pg_stat_statements 1202
Date
Msg-id 20081202170106.A0EC.52131E4D@oss.ntt.co.jp
Whole thread Raw
Responses Re: contrib/pg_stat_statements 1202  ("Vladimir Sitnikov" <sitnikov.vladimir@gmail.com>)
Re: contrib/pg_stat_statements 1202  ("Alex Hunsaker" <badalex@gmail.com>)
List pgsql-hackers
Here is an update version of contrib/pg_stat_statements.

New modifications from the last version are:
1. New counters in struct Instrumentation.
2. EXPLAIN ANALYZE VERBOSE shows buffer statistics in 'actual' section.
3. Buffer statistics counsters are not reset to zero anymore.

----
1. New counters in struct Instrumentation.
[in include/executor/instrument.h, backend/executor/instrument.c]

The following fields are added. They are used by pg_stat_statements
and EXPLAIN ANALYZE VERBOSE. getrusage() is called for each nodes.
Write-counters are not included because I think they are not so useful.

    buffer_gets;    /* # of buffer hits */
    buffer_hits;    /* # of buffer gets */
    buffile_reads;    /* # of buffile reads */
    utime;            /* user time in sec */
    stime;            /* sys time in sec */

----
2. EXPLAIN ANALYZE VERBOSE shows buffer statistics in 'actual' section.
[in backend/commands/explain.c]

I borrowed the idea from Vladimir,
"Buffer pool statistics in Explain Analyze".
http://archives.postgresql.org/message-id/1d709ecc0810111624i7419b179v1789b2ca681987c0@mail.gmail.com

Here is an sample output. We'd better to add a linebreak before
the 'actual' section because the line is too wide to display.

=# EXPLAIN ANALYZE VERBOSE SELECT * FROM accounts;
                                                                              QUERY PLAN

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Seq Scan on accounts  (cost=0.00..2688.29 rows=101829 width=97) (actual time=0.072..119.633 rows=100000 loops=1
gets=1670reads=1638 local_reads=0 CPU=0.06/0.03 sec) 
   Output: aid, bid, abalance, filler
 Total runtime: 209.556 ms
(3 rows)

----
3. Buffer statistics counsters are not reset to zero anymore.
[in storage/buffer/bufmgr.c]

ResetBufferUsage() is save the current counters in global variables as
baseline and buffer statistics are measured in difference from them
because the counters are used by struct Instrumentation.

----

Comments welcome.

Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center

Attachment

pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: New to_timestamp implementation is pretty strict
Next
From: Heikki Linnakangas
Date:
Subject: GIN index build speed