Re: 'Interesting' prepared statement slowdown on large table join - Mailing list pgsql-performance

From Jeff Janes
Subject Re: 'Interesting' prepared statement slowdown on large table join
Date
Msg-id BANLkTimw37BOr17G54KMS6r8cPZmTKnKkg@mail.gmail.com
Whole thread Raw
In response to Re: 'Interesting' prepared statement slowdown on large table join  ("Prodan, Andrei" <Andrei.Prodan@awinta.com>)
List pgsql-performance
On Thu, May 12, 2011 at 8:53 AM, Prodan, Andrei
<Andrei.Prodan@awinta.com> wrote:
>
> @Jeff: thank you for the clear plan interpretation - but I'm afraid I
> don't really understand the second bit:
> 1) I provided the GOOD plan, so we already know what postgres thinks,
> right? (Later edit: guess not. Doesn't work)
> 2) There's no full table scan in any of the plans - it scans indices,
> the problem seems to be that it scans them in the wrong order because it
> thinks there are very few WHERE matches in big_table - which is
> incorrect, as for that particular pair there is a huge amount of rows.

Hi Andrei,

"Explain analyze" only gives you the cost/rows for the plan components
it actually executed, it doesn't give you costs for alternative
rejected plans.  Since the GOOD PLAN doesn't include the index scan in
question, it doesn't give the estimated or actual rows for that scan
under the stats/conditions that provoke the GOOD PLAN to be adopted.
So to get that information, you have to design an experimental
prepared query that will get executed using that particular scan, that
way it will report the results I wanted to see.  My concern is that
the experimental query I proposed you use might instead decide to use
a full table scan rather than the desired index scan.   Although come
to think of it, I think the same code will be used to arrive at the
predicted number of rows regardless of whether it does a FTS or the
desired index scan.

Cheers,

Jeff

pgsql-performance by date:

Previous
From: Samuel Gendler
Date:
Subject: setting configuration values inside a stored proc
Next
From: Josh Berkus
Date:
Subject: Re: tuning on ec2