pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: jasiek <jasiek@klaster.net>
To: ow <oneway_111@yahoo.com>
To: pgsql-sql@postgresql.org
Subject: Re: Seq Scans when index expected to be used
Date: Sat, 29 Nov 2003 19:21:23 +0200
Message-ID: <20031129170913.M37199@klaster.net> (raw)
In-Reply-To: <20031129164924.51035.qmail@web21401.mail.yahoo.com>
References: <20031129164924.51035.qmail@web21401.mail.yahoo.com>

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



view thread (7+ messages)  latest in thread

Message-ID: <20031129170913.M37199@klaster.net>
Permalink:  ../20031129170913.M37199@klaster.net/
Also on:    postgresql.org/message-id/20031129170913.M37199@klaster.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: jasiek@klaster.net, oneway_111@yahoo.com
  Subject: Re: Seq Scans when index expected to be used
  In-Reply-To: <20031129170913.M37199@klaster.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox