Re: a change of query

From: "Chad Thompson" <chad(at)weblinkservices(dot)com>
To: "James Cooper" <jim(at)luckydigital(dot)com>, "sql" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: a change of query
Date: 2003-02-25 22:40:41
Message-ID: 06eb01c2dd1e$ee5488b0$32021aac@chad
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Rod Taylor 2003-02-25 22:50:04 Re: a change of query
Previous Message Brad Hilton 2003-02-25 22:39:17 Re: a change of query