Re: sort_mem statistics ...

Lists: pgsql-hackers
From: "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: sort_mem statistics ...
Date: 2005-10-18 20:07:55
Message-ID: 20051018170624.O995@ganymede.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


do we maintain anything anywhere for this? mainly, some way of
determining # of 'sorts to disk' vs 'sort in memory', to determine whether
or not sort_mem is set to a good value?

I don't think there is currently, but wondering how hard it would be to
get something like this added ... ?

thanks ..

----
Marc G. Fournier Hub.Org Networking Services (http://www.hub.org)
Email: scrappy(at)hub(dot)org Yahoo!: yscrappy ICQ: 7615664


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: sort_mem statistics ...
Date: 2005-10-18 22:15:02
Message-ID: 14404.1129673702@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

"Marc G. Fournier" <scrappy(at)postgresql(dot)org> writes:
> do we maintain anything anywhere for this? mainly, some way of
> determining # of 'sorts to disk' vs 'sort in memory', to determine whether
> or not sort_mem is set to a good value?

As of 8.1 you could turn on trace_sort to collect some data about this.

Looking at the code, I notice that the messages are all emitted at level
NOTICE. Perhaps that was not such a good idea --- it'd be pretty much
in-your-face if it were on all the time. Does anyone think it'd be a
good idea to emit the trace_sort messages at level LOG, instead?

regards, tom lane


From: "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: sort_mem statistics ...
Date: 2005-10-18 22:28:01
Message-ID: 20051018192722.M995@ganymede.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, 18 Oct 2005, Tom Lane wrote:

> "Marc G. Fournier" <scrappy(at)postgresql(dot)org> writes:
>> do we maintain anything anywhere for this? mainly, some way of
>> determining # of 'sorts to disk' vs 'sort in memory', to determine whether
>> or not sort_mem is set to a good value?
>
> As of 8.1 you could turn on trace_sort to collect some data about this.
>
> Looking at the code, I notice that the messages are all emitted at level
> NOTICE. Perhaps that was not such a good idea --- it'd be pretty much
> in-your-face if it were on all the time. Does anyone think it'd be a
> good idea to emit the trace_sort messages at level LOG, instead?

If someone sets trace_sort, does it matter what level its emit'd at? Its
not on by default, at least :)

----
Marc G. Fournier Hub.Org Networking Services (http://www.hub.org)
Email: scrappy(at)hub(dot)org Yahoo!: yscrappy ICQ: 7615664


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: sort_mem statistics ...
Date: 2005-10-18 22:57:16
Message-ID: 14977.1129676236@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

"Marc G. Fournier" <scrappy(at)postgresql(dot)org> writes:
> On Tue, 18 Oct 2005, Tom Lane wrote:
>> Looking at the code, I notice that the messages are all emitted at level
>> NOTICE. Perhaps that was not such a good idea --- it'd be pretty much
>> in-your-face if it were on all the time. Does anyone think it'd be a
>> good idea to emit the trace_sort messages at level LOG, instead?

> If someone sets trace_sort, does it matter what level its emit'd at?

Well, yeah. It depends whether you are thinking of the trace feature as
being used interactively, or as something turned on to gather data over
time in a production installation. In the second case you'd want the
info to go to the postmaster log, but not want to see it dumped on your
terminal all the time ...

regards, tom lane


From: "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: sort_mem statistics ...
Date: 2005-10-18 23:07:05
Message-ID: 20051018200648.A995@ganymede.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, 18 Oct 2005, Tom Lane wrote:

> "Marc G. Fournier" <scrappy(at)postgresql(dot)org> writes:
>> On Tue, 18 Oct 2005, Tom Lane wrote:
>>> Looking at the code, I notice that the messages are all emitted at level
>>> NOTICE. Perhaps that was not such a good idea --- it'd be pretty much
>>> in-your-face if it were on all the time. Does anyone think it'd be a
>>> good idea to emit the trace_sort messages at level LOG, instead?
>
>> If someone sets trace_sort, does it matter what level its emit'd at?
>
> Well, yeah. It depends whether you are thinking of the trace feature as
> being used interactively, or as something turned on to gather data over
> time in a production installation. In the second case you'd want the
> info to go to the postmaster log, but not want to see it dumped on your
> terminal all the time ...

Oops, sorry, I was thinking in terms of syslog log levels ... :(

----
Marc G. Fournier Hub.Org Networking Services (http://www.hub.org)
Email: scrappy(at)hub(dot)org Yahoo!: yscrappy ICQ: 7615664


From: Satoshi Nagayasu <nagayasus(at)nttdata(dot)co(dot)jp>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: sort_mem statistics ...
Date: 2005-10-19 00:33:32
Message-ID: 4355945C.6030909@nttdata.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom,

Tom Lane wrote:
>>do we maintain anything anywhere for this? mainly, some way of
>>determining # of 'sorts to disk' vs 'sort in memory', to determine whether
>>or not sort_mem is set to a good value?
>
> As of 8.1 you could turn on trace_sort to collect some data about this.

Why is the trace_sort option DEVELOPER_OPTIONS?

I think the sort statistics are *very* important for DBAs,
not only for developers (hackers).

Without any numerical evidence, trying (and error) to fitwork_mem value
will be painfull and wasting DBA's time.

And I want to get statistic info through system views, like pg_statio_*.

Please remember my previous post.
http://archives.postgresql.org/pgsql-patches/2005-09/msg00116.php

--
NAGAYASU Satoshi <nagayasus(at)nttdata(dot)co(dot)jp>


From: Josh Berkus <josh(at)agliodbs(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Satoshi Nagayasu <nagayasus(at)nttdata(dot)co(dot)jp>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>
Subject: Re: sort_mem statistics ...
Date: 2005-10-19 00:55:34
Message-ID: 200510181755.34677.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Satoshi,

> And I want to get statistic info through system views, like pg_statio_*.

I don't think anyone disagrees with that. It's just a little too late to
get in for 8.1.

--
--Josh

Josh Berkus
Aglio Database Solutions
San Francisco


From: Satoshi Nagayasu <nagayasus(at)nttdata(dot)co(dot)jp>
To: josh(at)agliodbs(dot)com
Cc: pgsql-hackers(at)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>
Subject: Re: sort_mem statistics ...
Date: 2005-10-19 01:17:21
Message-ID: 43559EA1.3040601@nttdata.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Josh Berkus wrote:
>>And I want to get statistic info through system views, like pg_statio_*.
>
> I don't think anyone disagrees with that. It's just a little too late to
> get in for 8.1.

Thanks for comment. I hope 8.2 will get it.

--
NAGAYASU Satoshi <nagayasus(at)nttdata(dot)co(dot)jp>


From: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>
To: "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: sort_mem statistics ...
Date: 2005-10-19 02:07:56
Message-ID: 4355AA7C.2090607@familyhealth.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

> do we maintain anything anywhere for this? mainly, some way of
> determining # of 'sorts to disk' vs 'sort in memory', to determine
> whether or not sort_mem is set to a good value?
>
> I don't think there is currently, but wondering how hard it would be to
> get something like this added ... ?

While on the subject of stats - is there any way to count the total
transactions that have occurred since the last stats reset? Do we track
that single number somewhere?

Chris


From: "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>
To: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>
Cc: "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: sort_mem statistics ...
Date: 2005-10-19 02:10:41
Message-ID: 20051018231026.D995@ganymede.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


Isn't that what pg_stat_database reports with its xact_commit and
xact_rollback values?

On Wed, 19 Oct 2005, Christopher Kings-Lynne wrote:

>> do we maintain anything anywhere for this? mainly, some way of determining
>> # of 'sorts to disk' vs 'sort in memory', to determine whether or not
>> sort_mem is set to a good value?
>>
>> I don't think there is currently, but wondering how hard it would be to get
>> something like this added ... ?
>
> While on the subject of stats - is there any way to count the total
> transactions that have occurred since the last stats reset? Do we track that
> single number somewhere?
>
> Chris
>
>

----
Marc G. Fournier Hub.Org Networking Services (http://www.hub.org)
Email: scrappy(at)hub(dot)org Yahoo!: yscrappy ICQ: 7615664


From: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>
To: "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: sort_mem statistics ...
Date: 2005-10-19 02:23:04
Message-ID: 4355AE08.5090209@familyhealth.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

> Isn't that what pg_stat_database reports with its xact_commit and
> xact_rollback values?

Ah yes. Doh :)

Chris


From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: sort_mem statistics ...
Date: 2005-10-24 22:24:32
Message-ID: 1130192672.8300.1102.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, 2005-10-18 at 18:57 -0400, Tom Lane wrote:
> "Marc G. Fournier" <scrappy(at)postgresql(dot)org> writes:
> > On Tue, 18 Oct 2005, Tom Lane wrote:
> >> Looking at the code, I notice that the messages are all emitted at level
> >> NOTICE. Perhaps that was not such a good idea --- it'd be pretty much
> >> in-your-face if it were on all the time. Does anyone think it'd be a
> >> good idea to emit the trace_sort messages at level LOG, instead?
>
> > If someone sets trace_sort, does it matter what level its emit'd at?
>
> Well, yeah. It depends whether you are thinking of the trace feature as
> being used interactively, or as something turned on to gather data over
> time in a production installation. In the second case you'd want the
> info to go to the postmaster log, but not want to see it dumped on your
> terminal all the time ...

Yes, please set this at LOG.

It will certainly provide many more data points for us to analyse.

Best Regards, Simon Riggs


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: sort_mem statistics ...
Date: 2005-10-25 01:09:03
Message-ID: 200510250109.j9P193h27830@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
> "Marc G. Fournier" <scrappy(at)postgresql(dot)org> writes:
> > On Tue, 18 Oct 2005, Tom Lane wrote:
> >> Looking at the code, I notice that the messages are all emitted at level
> >> NOTICE. Perhaps that was not such a good idea --- it'd be pretty much
> >> in-your-face if it were on all the time. Does anyone think it'd be a
> >> good idea to emit the trace_sort messages at level LOG, instead?
>
> > If someone sets trace_sort, does it matter what level its emit'd at?
>
> Well, yeah. It depends whether you are thinking of the trace feature as
> being used interactively, or as something turned on to gather data over
> time in a production installation. In the second case you'd want the
> info to go to the postmaster log, but not want to see it dumped on your
> terminal all the time ...

I think it should go to the logs, hence LOG. Right now it just scrolls
off my screen:

test=> select * from pg_class order by relname;
NOTICE: begin tuple sort: nkeys = 1, workMem = 1024, randomAccess = t
NOTICE: performsort starting: CPU 0.00s/0.00u sec elapsed 0.00 sec
NOTICE: performsort done: CPU 0.00s/0.00u sec elapsed 0.00 sec
NOTICE: sort ended: CPU 0.00s/0.00u sec elapsed 0.00 sec
relname | relnamespace | reltype | relowner |
relam | relfilenode | reltablespace | relpages | reltup
les | reltoastrelid | reltoastidxid | relhasindex | relisshared |
relkind | relnatts | relchecks | reltriggers | relukeys | relf
...

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: sort_mem statistics ...
Date: 2005-10-25 13:47:52
Message-ID: 200510251347.j9PDlqv16654@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Bruce Momjian wrote:
> Tom Lane wrote:
> > "Marc G. Fournier" <scrappy(at)postgresql(dot)org> writes:
> > > On Tue, 18 Oct 2005, Tom Lane wrote:
> > >> Looking at the code, I notice that the messages are all emitted at level
> > >> NOTICE. Perhaps that was not such a good idea --- it'd be pretty much
> > >> in-your-face if it were on all the time. Does anyone think it'd be a
> > >> good idea to emit the trace_sort messages at level LOG, instead?
> >
> > > If someone sets trace_sort, does it matter what level its emit'd at?
> >
> > Well, yeah. It depends whether you are thinking of the trace feature as
> > being used interactively, or as something turned on to gather data over
> > time in a production installation. In the second case you'd want the
> > info to go to the postmaster log, but not want to see it dumped on your
> > terminal all the time ...
>
> I think it should go to the logs, hence LOG. Right now it just scrolls
> off my screen:
>
> test=> select * from pg_class order by relname;
> NOTICE: begin tuple sort: nkeys = 1, workMem = 1024, randomAccess = t
> NOTICE: performsort starting: CPU 0.00s/0.00u sec elapsed 0.00 sec
> NOTICE: performsort done: CPU 0.00s/0.00u sec elapsed 0.00 sec
> NOTICE: sort ended: CPU 0.00s/0.00u sec elapsed 0.00 sec
> relname | relnamespace | reltype | relowner |
> relam | relfilenode | reltablespace | relpages | reltup
> les | reltoastrelid | reltoastidxid | relhasindex | relisshared |
> relkind | relnatts | relchecks | reltriggers | relukeys | relf
> ...

Simon also agrees, so changed to LOG in CVS.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: sort_mem statistics ...
Date: 2005-10-26 21:38:22
Message-ID: 20051026213822.GH16682@pervasive.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Oct 18, 2005 at 06:15:02PM -0400, Tom Lane wrote:
> "Marc G. Fournier" <scrappy(at)postgresql(dot)org> writes:
> > do we maintain anything anywhere for this? mainly, some way of
> > determining # of 'sorts to disk' vs 'sort in memory', to determine whether
> > or not sort_mem is set to a good value?
>
> As of 8.1 you could turn on trace_sort to collect some data about this.

While trace_sort is good, it doesn't really help for monitoring. What I
would find useful would be statistics along the lines of:

How many sorts have occured?
How many spilled to disk?
What's the largest amount of memory used by an in-memory sort?
What's the largest amount of memory used by an on-disk sort?
--
Jim C. Nasby, Sr. Engineering Consultant jnasby(at)pervasive(dot)com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461


From: "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>
To: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: sort_mem statistics ...
Date: 2005-10-26 21:50:49
Message-ID: 20051026184945.J993@ganymede.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, 26 Oct 2005, Jim C. Nasby wrote:

> On Tue, Oct 18, 2005 at 06:15:02PM -0400, Tom Lane wrote:
>> "Marc G. Fournier" <scrappy(at)postgresql(dot)org> writes:
>>> do we maintain anything anywhere for this? mainly, some way of
>>> determining # of 'sorts to disk' vs 'sort in memory', to determine whether
>>> or not sort_mem is set to a good value?
>>
>> As of 8.1 you could turn on trace_sort to collect some data about this.
>
> While trace_sort is good, it doesn't really help for monitoring. What I
> would find useful would be statistics along the lines of:
>
> How many sorts have occured?
> How many spilled to disk?
> What's the largest amount of memory used by an in-memory sort?
> What's the largest amount of memory used by an on-disk sort?

Actually, I'd like to see largest/smallest and average in this ... but if
all is being logged to syslog, I can easily determine those #s with a perl
script ..

----
Marc G. Fournier Hub.Org Networking Services (http://www.hub.org)
Email: scrappy(at)hub(dot)org Yahoo!: yscrappy ICQ: 7615664


From: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>
To: "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: sort_mem statistics ...
Date: 2005-10-26 22:00:23
Message-ID: 20051026220023.GL16682@pervasive.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Oct 26, 2005 at 06:50:49PM -0300, Marc G. Fournier wrote:
> On Wed, 26 Oct 2005, Jim C. Nasby wrote:
>
> >On Tue, Oct 18, 2005 at 06:15:02PM -0400, Tom Lane wrote:
> >>"Marc G. Fournier" <scrappy(at)postgresql(dot)org> writes:
> >>>do we maintain anything anywhere for this? mainly, some way of
> >>>determining # of 'sorts to disk' vs 'sort in memory', to determine
> >>>whether
> >>>or not sort_mem is set to a good value?
> >>
> >>As of 8.1 you could turn on trace_sort to collect some data about this.
> >
> >While trace_sort is good, it doesn't really help for monitoring. What I
> >would find useful would be statistics along the lines of:
> >
> >How many sorts have occured?
> >How many spilled to disk?
> >What's the largest amount of memory used by an in-memory sort?
> >What's the largest amount of memory used by an on-disk sort?
>
> Actually, I'd like to see largest/smallest and average in this ... but if
> all is being logged to syslog, I can easily determine those #s with a perl
> script ..

True, but like I said that doesn't help much for monitoring. I'm
generally concerned with finding out when stuff starts spilling to disk.

Is there a way to log only queries that spill to disk?
--
Jim C. Nasby, Sr. Engineering Consultant jnasby(at)pervasive(dot)com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461