Re: Strangely Variable Query Performance

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Steve <cheetah(at)tanabi(dot)org>
Cc: Scott Marlowe <smarlowe(at)g2switchworks(dot)com>, PostgreSQL Performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Strangely Variable Query Performance
Date: 2007-04-13 00:00:45
Message-ID: 10355.1176422445@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches pgsql-performance

Steve <cheetah(at)tanabi(dot)org> writes:
> With enable_seqscan=off I get:

> -> Bitmap Index Scan on detail_summary_receipt_encounter_idx
> (cost=0.00..4211395.17 rows=1099 width=0)
> Index Cond: ((receipt >= '1998-12-30'::date) AND (encounter_id =
> ANY ...

> The explain analyze is pending, running it now (however it doens't really
> appear to be any faster using this plan).

Yeah, that index is nearly useless for this query --- since the receipt
condition isn't really eliminating anything, it'll have to look at every
index entry :-( ... in fact, do so again for each of the IN arms :-( :-(
So it's definitely right not to want to use that plan. Question is, why
is it seemingly failing to consider the "right" index?

I'm busy setting up my test case on an x86_64 machine right now, but
I rather fear it'll still work just fine for me. Have you got any
nondefault parameter settings besides the ones you already mentioned?

Another thing that might be interesting, if you haven't got a problem
with exclusive-locking the table for a little bit, is

BEGIN;
DROP INDEX each index except detail_summary_encounter_id_idx
EXPLAIN the problem query
ROLLBACK;

just to see if it does the right thing when it's not distracted by
all the "wrong" indexes (yeah, I'm grasping at straws here). If you
set up the above as a SQL script it should only take a second to run.
Please try this with both settings of enable_seqscan --- you don't need
to do "explain analyze" though, we just want to know which plan it picks
and what the cost estimate is.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Steve 2007-04-13 00:05:48 Re: Strangely Variable Query Performance
Previous Message Steve 2007-04-12 23:42:49 Re: Strangely Variable Query Performance

Browse pgsql-patches by date

  From Date Subject
Next Message Steve 2007-04-13 00:05:48 Re: Strangely Variable Query Performance
Previous Message Steve 2007-04-12 23:42:49 Re: Strangely Variable Query Performance

Browse pgsql-performance by date

  From Date Subject
Next Message Steve 2007-04-13 00:05:48 Re: Strangely Variable Query Performance
Previous Message Steve 2007-04-12 23:42:49 Re: Strangely Variable Query Performance