pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas F.O'Connell <tfo@sitening.com>
To: Stephan Szabo <sszabo@megazone.bigpanda.com>
Cc: PgSQL - SQL <pgsql-sql@postgresql.org>
Subject: Re: Counting Distinct Records
Date: Tue, 16 Nov 2004 17:02:56 -0600
Message-ID: <A72D6B26-3823-11D9-95C2-000D93AE0944@sitening.com> (raw)
In-Reply-To: <20041116141911.K84773@megazone.bigpanda.com>
References: <1B2F7B00-3808-11D9-95C2-000D93AE0944@sitening.com>
	<20041116115807.E79990@megazone.bigpanda.com>
	<6E79C2FE-380B-11D9-95C2-000D93AE0944@sitening.com>
	<20041116141911.K84773@megazone.bigpanda.com>

Hmm. I was more interested in using COUNT( * ) than DISTINCT *.

I want a count of all rows, but I want to be able to specify which 
columns are distinct.

That's definitely an interesting approach, but testing doesn't show it 
to be appreciably faster.

If I do a DISTINCT *, postgres will attempt to guarantee that there are 
no duplicate values across all columns rather than a subset of columns? 
Is that right?

Anyway, I was just wondering if there were any best practices out there 
for counting distinct values in sets of values that might not 
themselves be distinct.

Thanks for the tips so far!

-tfo

--
Thomas F. O'Connell
Co-Founder, Information Architect
Sitening, LLC
http://www.sitening.com/
110 30th Avenue North, Suite 6
Nashville, TN 37203-6320
615-260-0005

On Nov 16, 2004, at 4:34 PM, Stephan Szabo wrote:

> On Tue, 16 Nov 2004, Thomas F.O'Connell wrote:
>
>> Is there another way to accomplish what the former is doing, then?
>
> The only thing I can think of is a subselect in from that uses 
> distinct.
>  select count(*) from (select distinct ...) foo
>
> That also theoretically allows you to use select distinct * inside the
> subselect.




view thread (7+ messages)  latest in thread

Message-ID: <A72D6B26-3823-11D9-95C2-000D93AE0944@sitening.com>
Permalink:  ../A72D6B26-3823-11D9-95C2-000D93AE0944@sitening.com/
Also on:    postgresql.org/message-id/A72D6B26-3823-11D9-95C2-000D93AE0944@sitening.com

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: tfo@sitening.com, sszabo@megazone.bigpanda.com
  Subject: Re: Counting Distinct Records
  In-Reply-To: <A72D6B26-3823-11D9-95C2-000D93AE0944@sitening.com>
  References: <1B2F7B00-3808-11D9-95C2-000D93AE0944@sitening.com> <20041116115807.E79990@megazone.bigpanda.com> <6E79C2FE-380B-11D9-95C2-000D93AE0944@sitening.com> <20041116141911.K84773@megazone.bigpanda.com> <A72D6B26-3823-11D9-95C2-000D93AE0944@sitening.com>

* 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