Re: How much expensive are row level statistics?

From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Michael Fuhr <mike(at)fuhr(dot)org>, Merlin Moncure <merlin(dot)moncure(at)rcsonline(dot)com>, pgsql-performance(at)postgresql(dot)org, Carlos Benkendorf <carlosbenkendorf(at)yahoo(dot)com(dot)br>
Subject: Re: How much expensive are row level statistics?
Date: 2005-12-16 13:17:25
Message-ID: 1134739045.2964.15.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches pgsql-performance

On Thu, 2005-12-15 at 19:06 -0500, Tom Lane wrote:
> Michael Fuhr <mike(at)fuhr(dot)org> writes:
> > Does the backend support, or could it be easily modified to support,
> > a mechanism that would post the command string after a configurable
> > amount of time had expired, and then continue processing the query?
>
> Not really, unless you want to add the overhead of setting a timer
> interrupt for every query. Which is sort of counterproductive when
> the motivation is to reduce overhead ...
>
> (It might be more or less free if you have statement_timeout set, since
> there would be a setitimer call anyway. But I don't think that's the
> norm.)

We could do the deferred send fairly easily. You need only set a timer
when stats_command_string = on, so we'd only do that when requested by
the admin. Overall, that would be a cheaper way of doing it than now.

However, I'm more inclined to the idea of a set of functions that allow
an administrator to retrieve the full SQL text executing in a backend,
with an option to return an EXPLAIN of the currently executing plan.
Right now, stats only gives you the first 1000 chars, so you're always
stuck if its a big query. Plus we don't yet have a way of getting the
exact EXPLAIN of a running query (you can get close, but it could
differ).

Pull is better than push. Asking specific backends what they're doing
when you need to know will be efficient; asking them to send their
command strings, all of the time, deferred or not will always be more
wasteful. Plus if you forgot to turn on stats_command_string before
execution, then you've no way of knowing anyhow.

Best Regards, Simon Riggs

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Trout 2005-12-16 13:56:44 Re: Which qsort is used
Previous Message Dann Corbit 2005-12-16 08:05:41 Re: Which qsort is used

Browse pgsql-patches by date

  From Date Subject
Next Message Simon Riggs 2005-12-16 18:40:18 Single-Transaction Utility options
Previous Message Kevin Brown 2005-12-16 05:44:58 Re: How much expensive are row level statistics?

Browse pgsql-performance by date

  From Date Subject
Next Message Harry Jackson 2005-12-16 13:38:24 Re: Crashing DB or Server?
Previous Message Moritz Bayer 2005-12-16 13:15:58 Crashing DB or Server?