From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Jeffrey Tenny <jeffrey(dot)tenny(at)comcast(dot)net> |
Cc: | "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>, pgsql-performance(at)postgresql(dot)org |
Subject: | Re: performance question (something to do w/ parameterized |
Date: | 2006-05-08 20:08:40 |
Message-ID: | 29345.1147118920@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-performance |
Jeffrey Tenny <jeffrey(dot)tenny(at)comcast(dot)net> writes:
> Well, since I don't know the exact parameter values, just substituting
> 1-650 for $1-$650, I get:
> Index Scan using testindex2 on x (cost=0.00..34964.52 rows=1503
> width=16) (actual time=0.201..968.252 rows=677 loops=1)
> Filter: ((f = 1) OR (f = 2) OR (f = 3) OR (f = 4) ...
> So index usage is presumably good on this one.
No, that's not a very nice plan at all --- the key thing to notice is
it says Filter: not Index Cond:. What you've actually got here is a
full-index scan over testindex2 (I guess it's doing that to achieve the
requested sort order), then computation of a 650-way boolean OR expression
for each row of the table. Ugh.
The other way of doing this would involve 650 separate index probes and
then sorting the result. Which would be pretty expensive too, but just
counting on my fingers it seems like that ought to come out at less than
the 35000 cost units for this plan. The planner evidently is coming up
with a different answer though. You might try dropping testindex2
(which I suppose is an index on (f,c)) so that it has only an index on
f to play with, and see what plan it picks and what the estimated/actual
costs are.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Jeffrey Tenny | 2006-05-08 20:33:46 | Re: performance question (something to do w/ parameterized |
Previous Message | Thomas Hallgren | 2006-05-08 20:06:18 | Re: Number of dimensions of an array parameter |
From | Date | Subject | |
---|---|---|---|
Next Message | Jeffrey Tenny | 2006-05-08 20:33:46 | Re: performance question (something to do w/ parameterized |
Previous Message | Alvaro Herrera | 2006-05-08 20:02:59 | Re: Query runs 38 seconds for small database! |