From: Robert Haas <robertmhaas@gmail.com>
To: Bryce Nesbitt <bryce2@obviously.com>
Cc: pgsql-performance@postgresql.org
Cc: Pavel Stehule <pavel.stehule@gmail.com>
Cc: Jorge Montero <jorge_montero@homedecorators.com>
Subject: Re: Re: 512,600ms query becomes 7500ms... but why? Postgres 8.3 query planner quirk?
Date: Thu, 11 Feb 2010 08:29:52 -0500
Message-ID: <603c8f071002110529t79977b62q29433ad02211918b@mail.gmail.com> (raw)
In-Reply-To: <4B7362DC.2060301@obviously.com>
References: <4B723042.7090406@obviously.com>
<4B726E81.2060904@obviously.com>
<603c8f071002101231k45e9161eyeacf9072219489eb@mail.gmail.com>
<4B7362DC.2060301@obviously.com>
On Wed, Feb 10, 2010 at 8:52 PM, Bryce Nesbitt <bryce2@obviously.com> wrote:
> If you guys succeed in making this class of query perform, you'll have beat
> out the professional consulting firm we hired, which was all but useless!
> The query is usually slow, but particular combinations of words seem to make
> it obscenely slow.
Heh heh heh professional consulting firm.
> production=# EXPLAIN ANALYZE SELECT context_key FROM article_words
> WHERE word_key = 3675;
> -------------------------------------------------------------------------------------------------------------------------------------------
> Index Scan using article_words_wc on article_words (cost=0.00..21433.53
> rows=11309 width=4) (actual time=0.025..7.579 rows=4003 loops=1)
> Index Cond: (word_key = 3675)
> Total runtime: 11.704 ms
That's surprisingly inaccurate. Since this table is large:
> production=# explain analyze select count(*) from article_words;
> Aggregate (cost=263831.63..263831.64 rows=1 width=0) (actual
> time=35851.654..35851.655 rows=1 loops=1)
> -> Seq Scan on words (cost=0.00..229311.30 rows=13808130 width=0)
> (actual time=0.043..21281.124 rows=13808184 loops=1)
> Total runtime: 35851.723 ms
...you may need to crank up the statistics target. I would probably
try cranking it all the way up to the max, though there is a risk that
might backfire, in which case you'll need to decrease it again.
ALTER TABLE article_words ALTER COLUMN word_key SET STATISTICS 1000;
That's probably not going to fix your whole problem, but it should be
interesting to see whether it makes things better or worse and by how
much.
...Robert
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-performance@postgresql.org
Cc: robertmhaas@gmail.com, bryce2@obviously.com, pavel.stehule@gmail.com, jorge_montero@homedecorators.com
Subject: Re: 512,600ms query becomes 7500ms... but why? Postgres 8.3 query planner quirk?
In-Reply-To: <603c8f071002110529t79977b62q29433ad02211918b@mail.gmail.com>
References: <4B723042.7090406@obviously.com> <4B726E81.2060904@obviously.com> <603c8f071002101231k45e9161eyeacf9072219489eb@mail.gmail.com> <4B7362DC.2060301@obviously.com> <603c8f071002110529t79977b62q29433ad02211918b@mail.gmail.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