From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Dave Cramer <pg(at)fastcrypt(dot)com> |
Cc: | postgresql performance list <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: Planner won't use composite index if there is an order by ???? |
Date: | 2008-04-25 00:23:27 |
Message-ID: | 11004.1209083007@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
Dave Cramer <pg(at)fastcrypt(dot)com> writes:
> Any idea why it wouldn't choose the right index ?
It thinks that way is cheaper. It's estimating its cost at 8381,
whereas selecting all the rows then sorting must take 10131 plus
some time to sort.
The reason why those estimates are so far off from reality is directly
tied to the 400-estimated-vs-2-actual rowcount estimation error.
I'm not sure how much of that could be fixed by raising the stats target
for the table, but that's certainly something to try.
Another thing you should look at is eliminating dependences between
columns. I'll bet that the "scored_at is not null" condition is either
redundant with the "score in ..." condition, or could be made so (ie
force score to null when scored_at is null). If you could get rid of
the separate test on scored_at, it'd help to avoid the estimation weak
spot of correlated restrictions.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Marc G. Fournier | 2008-04-25 01:09:49 | Re: off-topic: SPAM |
Previous Message | Dave Cramer | 2008-04-25 00:06:01 | Planner won't use composite index if there is an order by ???? |