From: Shaun Thomas <sthomas@peak6.com>
To: Prodan, Andrei <Andrei.Prodan@awinta.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: 'Interesting' prepared statement slowdown on large table join
Date: Wed, 11 May 2011 10:55:27 -0500
Message-ID: <4DCAB16F.2060300@peak6.com> (raw)
In-Reply-To: <D33393149C01874DB3D72FE46A1B268B0C784D@vpmail05-x.intra.ads-root.de>
References: <D33393149C01874DB3D72FE46A1B268B0C784D@vpmail05-x.intra.ads-root.de>
On 05/11/2011 06:08 AM, Prodan, Andrei wrote:
> Index Scan using attr_name_value on big_table (cost=0.00..22.85
> rows=4 width=7) (actual time=0.176..757.646 rows=914786 loops=1)
Holy inaccurate statistics, Batman!
Try increasing your statistics target for attr_name and attr_value in
your big table. I know you said you set it to 300 on party_id, but what
happened here is that the optimizer thought this particular name/value
combo in your big table would return less rows, and it was horribly,
horribly wrong.
You might think about bumping up your default_statistics_target anyway
to prevent problems like this in general. But definitely increase it on
those two columns and reanalyze. My guess is that your big_table is big
enough that each analyze gets a different random sample of the various
attr_name and attr_value combinations, so occasionally it'll get too few
and start badly skewing query plans.
--
Shaun Thomas
OptionsHouse | 141 W. Jackson Blvd. | Suite 800 | Chicago IL, 60604
312-676-8870
sthomas@peak6.com
______________________________________________
See http://www.peak6.com/email_disclaimer.php
for terms and conditions related to this email
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: sthomas@peak6.com, Andrei.Prodan@awinta.com
Subject: Re: 'Interesting' prepared statement slowdown on large table join
In-Reply-To: <4DCAB16F.2060300@peak6.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox