Re: [PATCH] Improve EXPLAIN ANALYZE overhead by sampling

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [PATCH] Improve EXPLAIN ANALYZE overhead by sampling
Date: 2006-06-01 13:35:43
Message-ID: 11426.1149168943@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Martijn van Oosterhout <kleptog(at)svana(dot)org> writes:
> I note Tom made some changes to this patch after it went in. For the
> record, it was always my intention that samplecount count the number of
> _tuples_ returned while sampling, rather than the number of
> _iterations_. I'll admit the comment in the header was wrong.

> While my original patch had a small error in the case of multiple
> tuples returned, it would've been correctable by counting the actual
> number of sample. The way it is now, it will show a bias if the number
> of tuples returned increases after the first sampled 50 tuples.

How so? The number of tuples doesn't enter into it at all. What the
code is now assuming is that the time per node iteration is constant.
More importantly, it's subtracting off an overhead estimate that's
measured per iteration. In the math you had before, the overhead was
effectively assumed to be per tuple, which is clearly wrong.

For nodes that return a variable number of tuples, it might be sensible
to presume that the node iteration time is roughly linear in the number
of tuples returned, but I find that debatable. In any case the sampling
overhead is certainly not dependent on how many tuples an iteration
returns.

This is all really moot at the moment, since we have only two kinds of
nodes: those that always return 1 tuple (until done) and those that
return all their tuples in a single iteration. If we ever get into
nodes that return varying numbers of tuples per iteration --- say,
exposing btree's page-at-a-time behavior at the plan node level ---
we'd have to rethink this. But AFAICS we'd need to count both tuples
and iterations to have a model that made any sense at all, so the
extra counter I added is needed anyway.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Zdenek Kotala 2006-06-01 14:56:10 Re: Allow commenting of variables in postgresql.conf to -
Previous Message Martijn van Oosterhout 2006-06-01 13:30:08 Re: CTID issues and a soc student in need of help

Browse pgsql-patches by date

  From Date Subject
Next Message Zdenek Kotala 2006-06-01 14:56:10 Re: Allow commenting of variables in postgresql.conf to -
Previous Message Peter Eisentraut 2006-06-01 13:04:36 Re: [PATCH] Add support for GnuTLS