Nested Loop WAS: VACUUM ANALYZE makes things worse!

Started by Ian Hardingabout 24 years ago3 messagesgeneral
Jump to latest
#1Ian Harding
ianh@tpchd.org

Doh! I set enable_seqscan = off and things are snappy again.

Same problem though, how can I fix the query so the optimizer comes to the same conclusion?

Thanks,

Ian A. Harding
Programmer/Analyst II
Tacoma-Pierce County Health Department
(253) 798-3549
mailto: iharding@tpchd.org

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Ian Harding (#1)
Re: Nested Loop WAS: VACUUM ANALYZE makes things worse!

"Ian Harding" <ianh@tpchd.org> writes:

Doh! I set enable_seqscan = off and things are snappy again.
Same problem though, how can I fix the query so the optimizer comes to the same conclusion?

I notice that in the "before" state, the planner thinks there will be
some thousands of rows coming out of each join, but in the "after"
state only one row. Which of these is more correct? (If you are
running 7.2, it'd be helpful to show EXPLAIN ANALYZE not just
EXPLAIN results for each case.)

regards, tom lane

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Tom Lane (#2)
Re: Nested Loop WAS: VACUUM ANALYZE makes things worse!

"Ian Harding" <ianh@tpchd.org> writes:

Another case of blockhead programmer. I must have been smoking something when I wrote that piece of junk. I collapsed it into a single query with sum(CASE WHEN DAYNUMBER = X THEN HOURS ELSE NULL) for the hours and it works like clockwork.
Sorry about the noise.

I was wondering if you couldn't simplify it ;-) ... but the question of
why the plan got worse after VACUUM ANALYZE is still interesting. At
least to me.

regards, tom lane