pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feeda change of query
4+ messages / 4 participants
[nested] [flat]
* a change of query
@ 2003-02-25 22:03 James Cooper <jim@luckydigital.com>
0 siblings, 3 replies; 4+ messages in thread
From: James Cooper @ 2003-02-25 22:03 UTC (permalink / raw)
To: pgsql-sql
select distinct cp.person_id from cluster_person cp, cluster c where cp.cluster_id = c.cluster_id and c.c_id = 1
can this query be changed to give just the row count?( of the distinct rows )
yes: i am aware of count() but this wont count the distinct rows - I can however achive this with an nested person_id in(select... etc but that slows things down big time!!!!
the above quey gives me my resultset asap - is there a way to get just the number of rows with the same speed
My thoughts are that I could just make a plpgsql function with a GET Diagniostics ROW_COUNT -
thoughts?
James
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: a change of query
@ 2003-02-25 22:39 Brad Hilton <bhilton@vpop.net>
parent: James Cooper <jim@luckydigital.com>
2 siblings, 0 replies; 4+ messages in thread
From: Brad Hilton @ 2003-02-25 22:39 UTC (permalink / raw)
To: James Cooper <jim@luckydigital.com>; +Cc: pgsql-sql
On Tue, 2003-02-25 at 14:03, James Cooper wrote:
> select distinct cp.person_id from cluster_person cp, cluster c where
> cp.cluster_id = c.cluster_id and c.c_id = 1
>
> can this query be changed to give just the row count?( of the distinct
> rows )
select count(distinct cp.person_id) from ...
Is that what you were after?
Brad Hilton
VPOP Technologies, Inc.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: a change of query
@ 2003-02-25 22:40 Chad Thompson <chad@weblinkservices.com>
parent: James Cooper <jim@luckydigital.com>
2 siblings, 0 replies; 4+ messages in thread
From: Chad Thompson @ 2003-02-25 22:40 UTC (permalink / raw)
To: James Cooper <jim@luckydigital.com>; pgsql-sql
how about
select count(distinct cp.person_id) from cluster_person cp, cluster c where cp.cluster_id = c.cluster_id and c.c_id = 1
Is that as fast?
Chad
----- Original Message -----
From: James Cooper
To: sql
Sent: Tuesday, February 25, 2003 3:03 PM
Subject: [SQL] a change of query
select distinct cp.person_id from cluster_person cp, cluster c where cp.cluster_id = c.cluster_id and c.c_id = 1
can this query be changed to give just the row count?( of the distinct rows )
yes: i am aware of count() but this wont count the distinct rows - I can however achive this with an nested person_id in(select... etc but that slows things down big time!!!!
the above quey gives me my resultset asap - is there a way to get just the number of rows with the same speed
My thoughts are that I could just make a plpgsql function with a GET Diagniostics ROW_COUNT -
thoughts?
James
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: a change of query
@ 2003-02-25 22:50 Rod Taylor <rbt@rbt.ca>
parent: James Cooper <jim@luckydigital.com>
2 siblings, 0 replies; 4+ messages in thread
From: Rod Taylor @ 2003-02-25 22:50 UTC (permalink / raw)
To: James Cooper <jim@luckydigital.com>; +Cc: pgsql-sql
On Tue, 2003-02-25 at 17:03, James Cooper wrote:
> select distinct cp.person_id from cluster_person cp, cluster c where
> cp.cluster_id = c.cluster_id and c.c_id = 1
>
> can this query be changed to give just the row count?( of the distinct
> rows )
:) So close
select count(distinct cp.person_id) from...
--
Rod Taylor <rbt@rbt.ca>
PGP Key: http://www.rbt.ca/rbtpub.asc
Attachments:
signature.asc (application/pgp-signature, 186B) download
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2003-02-25 22:50 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-02-25 22:03 a change of query James Cooper <jim@luckydigital.com>
2003-02-25 22:39 ` Brad Hilton <bhilton@vpop.net>
2003-02-25 22:40 ` Chad Thompson <chad@weblinkservices.com>
2003-02-25 22:50 ` Rod Taylor <rbt@rbt.ca>
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