Re: [ADMIN] Tuning questions..

2001-12-19 Thread Bojan Belovic
This in interesting effect, that I ran into more than once, and I have a question concerning this: We see that the cost for this query went from roughly 12,000,000 to about 12,000. Of course, we cannot assume that the time of execution will be directly proportional to this, and also, the weight fa

Re: [[ADMIN] Tuning questions..]

2001-12-19 Thread Michael T. Halligan
Thanks, that sped things up a bit, from 7.6 sec. to about 5.5 sec. However the plan still includes a sequential scan on ssa_candidate: Aggregate (cost=12161.11..12161.11 rows=1 width=35) -> Merge Join (cost=11611.57..12111.12 rows=19996 width=35) -> Sort (cost=11488.27..11488.27 r

Re: [[ADMIN] Tuning questions..]

2001-12-19 Thread Bojan Belovic
Not sure about tuning, but it seems to me that this query would be much more effective if it's rewritten like this (especially if style_id columns on both tables are indexed): SELECT count(DISTINCT song_id) AS X FROM ssa_candidate SC JOIN station_subgenre SS ON SC.style_id = SS.style_id WHERE SS.

Re: [ADMIN] Tuning questions..

2001-12-19 Thread Tom Lane
"Michael T. Halligan" <[EMAIL PROTECTED]> writes: > The query sorts through about 80k rows.. here's the query > -- > SELECT count(*) FROM ( > SELECT DISTINCT song_id FROM ssa_candidate WHERE > style_id IN ( >