X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 995DF475A37 for ; Tue, 25 Feb 2003 18:06:01 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 11536-06 for ; Tue, 25 Feb 2003 18:05:33 -0500 (EST) Received: from utahisp.com (utahisp.com [66.239.12.3]) by postgresql.org (Postfix) with ESMTP id 8B12D475CCE for ; Tue, 25 Feb 2003 17:44:02 -0500 (EST) Received: from chad [63.230.8.76] by utahisp.com (SMTPD32-7.14) id A1522B1E0280; Tue, 25 Feb 2003 15:42:26 -0700 Message-ID: <06eb01c2dd1e$ee5488b0$32021aac@chad> From: "Chad Thompson" To: "James Cooper" , "sql" References: <004a01c2dd19$be6fe400$c900a8c0@jax> Subject: Re: a change of query Date: Tue, 25 Feb 2003 15:40:41 -0700 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_06E8_01C2DCE4.40F04EA0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2720.3000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Declude-Sender: chad@weblinkservices.com [63.230.8.76] X-Note: This E-mail was scanned by Declude JunkMail (www.declude.com) for spam. X-Virus-Scanned: by amavisd-new X-Archive-Number: 200302/567 X-Sequence-Number: 11965 This is a multi-part message in MIME format. ------=_NextPart_000_06E8_01C2DCE4.40F04EA0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable how about=20 select count(distinct cp.person_id) from cluster_person cp, cluster c where= cp.cluster_id =3D c.cluster_id and c.c_id =3D 1 Is that as fast? Chad ----- Original Message -----=20 From: James Cooper=20 To: sql=20 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.c= luster_id =3D c.cluster_id and c.c_id =3D 1 can this query be changed to give just the row count?( of the distinct ro= ws ) 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 slow= s things down big time!!!! the above quey gives me my resultset asap - is there a way to get just th= e number of rows with the same speed My thoughts are that I could just make a plpgsql function with a GET Dia= gniostics ROW_COUNT -=20 thoughts? James ------=_NextPart_000_06E8_01C2DCE4.40F04EA0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
how about
select count(distinct cp.person_id) from cluster_person cp, cluste= r=20 c where cp.cluster_id =3D c.cluster_id and c.c_id =3D 1
 
Is that as fast?
Chad
----- Original Message -----
Fro= m:=20 Jame= s=20 Cooper
To: sql
Sent: Tuesday, February 25, 2003 3= :03=20 PM
Subject: [SQL] a change of query

select distinct cp.person_id from cluster_person cp, cluster c where cp.cluster_id =3D c.cluster_id and c.c_id =3D 1

can this query be changed to give just the row count?( = of the=20 distinct rows )

yes: i am aware of count() but this wont count the dist= inct=20 rows - I can however achive this with an nested person_id in(select... et= c=20 but that slows things down big time!!!!

the above quey gives me my resultset asap - is there a = way to=20 get just the number of rows with the same speed

My thoughts are that I could just make a plpgsql = =20 function with a GET Diagniostics ROW_COUNT -

thoughts?

 

James

 

------=_NextPart_000_06E8_01C2DCE4.40F04EA0--