Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patchespgsql-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

pgsql-performance by date

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

pgsql-hackers by date

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

pgsql-patches by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group