From: Steinar H. Gunderson <sgunderson@bigfoot.com>
To: pgsql-performance@postgresql.org
Subject: Re: group by will not use an index?
Date: Wed, 10 Jan 2007 02:11:04 +0100
Message-ID: <20070110011104.GA21351@uio.no> (raw)
In-Reply-To: <20070110010703.7815.qmail@web52315.mail.yahoo.com>
References: <20070110010703.7815.qmail@web52315.mail.yahoo.com>
On Tue, Jan 09, 2007 at 05:07:03PM -0800, Brian Herlihy wrote:
> Actually, as I recently discovered, GROUP BY is faster than DISTINCT. It's
> just due to how they are implemented, so don't go looking for any deep
> reason :) The thread "GROUP BY vs DISTINCT" from 2006-12-20 discusses it.
> DISTINCT sorts the results to find the unique rows, but GROUP BY uses a
> hash.
Actually, GROUP BY _can_ use a sort too, it's just that a hash is usually
faster.
/* Steinar */
--
Homepage: http://www.sesse.net/
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 using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: sgunderson@bigfoot.com
Subject: Re: group by will not use an index?
In-Reply-To: <20070110011104.GA21351@uio.no>
* 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