Re: slow query, different plans - Mailing list pgsql-performance

From Tom Lane
Subject Re: slow query, different plans
Date
Msg-id 25289.1344061602@sss.pgh.pa.us
Whole thread Raw
In response to slow query, different plans  ("Midge Brown" <midgems@sbcglobal.net>)
List pgsql-performance
"Midge Brown" <midgems@sbcglobal.net> writes:
> I'm having a problem with a query on our production server, but not on a laptop running a similar postgres version
witha recent backup copy of the same table. I tried reindexing the table on the production server, but it didn't make
anydifference. Other queries on the same table are plenty fast.  

Reindexing won't help that.  The problem is a bad statistical estimate;
it thinks there are about 700 rows with applies2 = 256, when there's
really only one.  That means the "fast" plan is a lot faster than the
planner gives it credit for, and conversely the "slow" plan is a lot
slower than the planner is expecting.  Their estimated costs end up
nearly the same, which makes it a bit of a chance matter which one is
picked --- but the true costs are a lot different.  So you need to fix
that rowcount estimate.  Raising the stats target for the table might
help.

            regards, tom lane

pgsql-performance by date:

Previous
From: Greg Williamson
Date:
Subject: Re: slow query, different plans
Next
From: Magnus Hagander
Date:
Subject: Re: Postgres 9.1.4 - high stats collector IO usage