Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 4B2FE2E003C for ; Sun, 15 Jun 2008 12:00:27 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 90462-09 for ; Sun, 15 Jun 2008 12:00:24 -0300 (ADT) X-Greylist: delayed 00:07:03.568307 by SQLgrey-1.7.6 Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.249]) by developer.postgresql.org (Postfix) with ESMTP id D345B2E003A for ; Sun, 15 Jun 2008 12:00:23 -0300 (ADT) Received: by an-out-0708.google.com with SMTP id d30so1055530and.33 for ; Sun, 15 Jun 2008 08:00:23 -0700 (PDT) Received: by 10.101.68.10 with SMTP id v10mr6548206ank.45.1213541594332; Sun, 15 Jun 2008 07:53:14 -0700 (PDT) Received: from ?192.168.1.152? ( [71.176.213.27]) by mx.google.com with ESMTPS id 6sm7724173ywc.8.2008.06.15.07.53.10 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 15 Jun 2008 07:53:12 -0700 (PDT) References: <48551DB0.8050507@gmail.com> <88daf38c0806150703s24f7736fuc88aded848186af4@mail.gmail.com> <8ea917510806150741i1fb1a2dfhb3fe71eac2573dd1@mail.gmail.com> Message-Id: <2AE1C749-45BA-4926-8065-38FD6EC0E861@myyearbook.com> From: "Gavin M. Roy" To: Uwe Bartels In-Reply-To: <8ea917510806150741i1fb1a2dfhb3fe71eac2573dd1@mail.gmail.com> Content-Type: multipart/alternative; boundary=Apple-Mail-1--988813752 X-Mailer: iPhone Mail (4A102) Mime-Version: 1.0 (iPhone Mail 4A102) Subject: Re: how to find the sql using most of the i/o in an oltp system Date: Sun, 15 Jun 2008 10:53:06 -0400 Cc: Alexander Staubo , "pgsql-performance@postgresql.org" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200806/54 X-Sequence-Number: 30404 --Apple-Mail-1--988813752 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Check out pgFouine. Sent from my iPhone On Jun 15, 2008, at 10:41 AM, "Uwe Bartels" wrote: > Hi Alexander, > > thanks for you answer. > What you wrote in terms of postgres I knew. I just tested to log all > statements with statistics. This is a lot of unstructured data in a > logfile. But this is the best I found as far. > > The database is running on a solaris box. So DTrace is no problem. I > couldn't find any dtrace scripts for postgres. Do you know any > scripts except this sample script? > > Thanks. > Uwe > > On Sun, Jun 15, 2008 at 4:03 PM, Alexander Staubo > wrote: > On Sun, Jun 15, 2008 at 3:48 PM, Uwe Bartels > wrote: > > Tuning a sql statements I'm familiar with. Finding a sql statement > which > > takes too long due to i/o is probably easy as well. But how about > statements > > that take about 100 ms, that read a lot and that are executed > several times > > per second? > > Take a look at the PostgreSQL manual chapter on monitoring and > statistics: > > http://www.postgresql.org/docs/8.3/interactive/monitoring.html > > If you have access to DTrace (available on Solaris, OS X and possibly > FreeBSD), you could hook the low-level system calls to reads and > writes. If you don't have access to DTrace, the pg_statio_* set of > tables is your main option. In particular, pg_statio_user_tables and > pg_statio_user_indexes. See the documentation for the meaning of the > individual columns. > > Unfortunately, the statistics tables are not transaction-specific > (indeed I believe they only update once you commit the transaction, > and then only after a delay), meaning they capture statistics about > everything currently going on in the database. The only way to capture > statistics about a single query, then, is to run it in complete > isolation. > > Alexander. > --Apple-Mail-1--988813752 Content-Transfer-Encoding: 7bit Content-Type: text/html; charset=UTF-8
Check out pgFouine.

Sent from my iPhone

On Jun 15, 2008, at 10:41 AM, "Uwe Bartels" <uwe.bartels@gmail.com> wrote:

Hi Alexander,

thanks for you answer.
What you wrote in terms of postgres I knew. I just tested to log all statements with statistics. This is a lot of unstructured data in a logfile. But this is the best I found as far.

The database is running on a solaris box. So DTrace is no problem. I couldn't find any dtrace scripts for postgres. Do you know any scripts except this sample script?

Thanks.
Uwe

On Sun, Jun 15, 2008 at 4:03 PM, Alexander Staubo <alex@bengler.no> wrote:
On Sun, Jun 15, 2008 at 3:48 PM, Uwe Bartels <uwe.bartels@gmail.com> wrote:
> Tuning a sql statements I'm familiar with. Finding a sql statement which
> takes too long due to i/o is probably easy as well. But how about statements
> that take about 100 ms, that read a lot and that are executed several times
> per second?

Take a look at the PostgreSQL manual chapter on monitoring and statistics:

 http://www.postgresql.org/docs/8.3/interactive/monitoring.html

If you have access to DTrace (available on Solaris, OS X and possibly
FreeBSD), you could hook the low-level system calls to reads and
writes. If you don't have access to DTrace, the pg_statio_* set of
tables is your main option. In particular, pg_statio_user_tables and
pg_statio_user_indexes. See the documentation for the meaning of the
individual columns.

Unfortunately, the statistics tables are not transaction-specific
(indeed I believe they only update once you commit the transaction,
and then only after a delay), meaning they capture statistics about
everything currently going on in the database. The only way to capture
statistics about a single query, then, is to run it in complete
isolation.

Alexander.

--Apple-Mail-1--988813752--