Skip site navigation (1) Skip section navigation (2)

contrib/pg_stat_statements

From: ITAGAKI Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
To: pgsql-hackers(at)postgresql(dot)org
Subject: contrib/pg_stat_statements
Date: 2008-10-11 09:05:35
Message-ID: 20081011172450.3402.52131E4D@oss.ntt.co.jp (view raw or flat)
Thread:
Lists: pgsql-hackers
Hello,

Postgres has configurations to log statements into server logs, but there
are few convenience ways to summarize the logs as a view. Some external
projects like pgFouine or PQA have the functionality, but they consume
much CPU resources and cannot summarize in real-time -- summarize-time
is longer than write-time of the logs in heavily loads.

I'd like to submit pg_stat_statements contrib module, that counts up
incoming statements in shared memory and summarizes the result as a view.
It is just a statements-version of pg_stat_user_functions.

Information collected by the view are:
  - query string
  - total_time and cpu_time
  - buffer access (gets, reads, writes, local reads and local writes)
  - number of rows retrieved or affected
(There is a sample output in sgml in the attached tarball.)

I attach WIP version of the module. auto_explain.patch is also required
because the module uses a new version DefineCustomVariable.
http://archives.postgresql.org/message-id/20081009165157.9BE4.52131E4D@oss.ntt.co.jp
The module allocates fixed share memory at the server start and store
statements statistics in it. On out of memory, least recently used
statements are discarded.

Comments and suggenstions welcome!

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


Attachment: pg_stat_statements-1011.tgz
Description: application/octet-stream (5.9 KB)
Attachment: pgstatstatements.sgml
Description: application/octet-stream (8.2 KB)

Responses

pgsql-hackers by date

Next:From: Zdenek KotalaDate: 2008-10-11 09:40:50
Subject: pg_upgrade: convert on read is dead end
Previous:From: Benedek LászlóDate: 2008-10-11 06:45:16
Subject: Re: pg_dump roles support

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group