Re: Seq Scans when index expected to be used - Mailing list pgsql-sql

From jasiek
Subject Re: Seq Scans when index expected to be used
Date
Msg-id 20031129170913.M37199@klaster.net
Whole thread Raw
In response to Seq Scans when index expected to be used  (ow <oneway_111@yahoo.com>)
Responses Re: Seq Scans when index expected to be used  (Joe Conway <mail@joeconway.com>)
List pgsql-sql
On Sat, 29 Nov 2003 08:49:24 -0800 (PST), ow wrote
> explain select b, c, a
> from test
> group by b, c, a
> having count(*) > 1

I'm not sure about 7.4 aggregate improvements, but <=7.3 didn't work good 
with aggregates at all. Maybe it's not directly an answer to your question, 
but try theses queries:

select t1.b,t1.c,t1.a from test t1 join test t2 using (b,c,a)
where t2.id<>t1.id
group by t1.b,t1.c,t1.a

or

select a,b,c from test t1
where exists (select * from test t2 where t2.a=t1.a and t2.b=t1.b and 
t2.c=t1.c and t1.id<>t2.id)
group by a,b,c

Regards,
Tomasz Myrta


pgsql-sql by date:

Previous
From: ow
Date:
Subject: Seq Scans when index expected to be used
Next
From: Tom Lane
Date:
Subject: Re: Seq Scans when index expected to be used