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

2008-10-09 Thread Jussi Pakkanen
The following bug has been logged online: Bug reference: 4462 Logged by: Jussi Pakkanen Email address: [EMAIL PROTECTED] PostgreSQL version: 8.3.3 Operating system: Ubuntu x86 8/04 Description:Adding COUNT to query causes massive slowdown Details: I have a table in

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; >>

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-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