From: Thomas F.O'Connell <tfo@sitening.com>
To: PgSQL - SQL <pgsql-sql@postgresql.org>
Subject: Counting Distinct Records
Date: Tue, 16 Nov 2004 13:45:45 -0600
Message-ID: <1B2F7B00-3808-11D9-95C2-000D93AE0944@sitening.com> (raw)
I am wondering whether the following two forms of SELECT statements are
logically equivalent:
SELECT COUNT( DISTINCT table.column ) ...
and
SELECT DISTINCT COUNT( * ) ...
If they are the same, then why is the latter query much slower in
postgres when applied to the same FROM and WHERE clauses?
Furthermore, is there a better way of performing this sort of operation
in postgres (or just in SQL in general)?
Thanks!
-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
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
Subject: Re: Counting Distinct Records
In-Reply-To: <1B2F7B00-3808-11D9-95C2-000D93AE0944@sitening.com>
References: <1B2F7B00-3808-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