Re: [BUGS] BUG #4462: Adding COUNT to query causes massive slowdown

2008-10-15 Thread Jussi Pakkanen
On Sat, Oct 11, 2008 at 12:07 AM, Tom Lane <[EMAIL PROTECTED]> wrote: > The sort-and-uniq doesn't care where the data came from. But if we have > to feed it all rows of the table, as we do here, we're going to use a > seqscan. An indexscan can never beat a seqscan for retrieving the whole > tabl

Re: [BUGS] BUG #4462: Adding COUNT to query causes massive slowdown

2008-10-10 Thread Tom Lane
"Jussi Pakkanen" <[EMAIL PROTECTED]> writes: > On Thu, Oct 9, 2008 at 6:55 PM, Tom Lane <[EMAIL PROTECTED]> wrote: >> Try (3) COUNT(DISTINCT x) ... or any DISTINCT aggregate for that matter >> ... is implemented by a sort-and-uniq step inside the aggregate function >> itself. You can't see it in t

Re: [BUGS] BUG #4462: Adding COUNT to query causes massive slowdown

2008-10-10 Thread Jussi Pakkanen
On Thu, Oct 9, 2008 at 6:55 PM, Tom Lane <[EMAIL PROTECTED]> wrote: >> Given that PostgreSQL does the scan even with the huge seqscan >> penalty, I can think of only two different causes: >> 1) some sort of a bug in the query analyzer >> 2) SELECT COUNT(DISTINCT x) for some reason requires informa

Re: [BUGS] BUG #4462: Adding COUNT to query causes massive slowdown

2008-10-09 Thread Tom Lane
"Jussi Pakkanen" <[EMAIL PROTECTED]> writes: > Given that PostgreSQL does the scan even with the huge seqscan > penalty, I can think of only two different causes: > 1) some sort of a bug in the query analyzer > 2) SELECT COUNT(DISTINCT x) for some reason requires information that > is not available

Re: [BUGS] BUG #4462: Adding COUNT to query causes massive slowdown

2008-10-09 Thread Jussi Pakkanen
On Thu, Oct 9, 2008 at 3:05 PM, Peter Eisentraut <[EMAIL PROTECTED]> wrote: > Jussi Pakkanen wrote: >> >> However when I try to count the amount of distinct codes, I get this: >> >> >> EXPLAIN SELECT COUNT(DISTINCT code) FROM log; >> QUERY PLAN >> >> -

Re: [BUGS] BUG #4462: Adding COUNT to query causes massive slowdown

2008-10-09 Thread Peter Eisentraut
Jussi Pakkanen wrote: However when I try to count the amount of distinct codes, I get this: EXPLAIN SELECT COUNT(DISTINCT code) FROM log; QUERY PLAN - Aggregate (cost=100801488.