X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id D02699FA5C8 for ; Thu, 1 Jun 2006 15:59:20 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 53598-02 for ; Thu, 1 Jun 2006 15:59:11 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.enyo.de (mail.enyo.de [212.9.189.167]) by postgresql.org (Postfix) with ESMTP id B6D939FA040 for ; Thu, 1 Jun 2006 15:59:11 -0300 (ADT) Received: from deneb.vpn.enyo.de ([212.9.189.177] helo=deneb.enyo.de) by mail.enyo.de with esmtp id 1FlsNx-0006Zx-0X; Thu, 01 Jun 2006 20:59:09 +0200 Received: from fw by deneb.enyo.de with local (Exim 4.62) (envelope-from ) id 1FlsNt-0002hn-6x; Thu, 01 Jun 2006 20:59:05 +0200 From: Florian Weimer To: Miroslav ?ulc Cc: pgsql-sql@postgresql.org Subject: Re: SELECT DISTINCT too slow References: <447EEAF1.7040305@startnet.cz> <12554.1149175230@sss.pgh.pa.us> <447F0A44.3080500@startnet.cz> <20060601154613.GC19388@surnet.cl> Date: Thu, 01 Jun 2006 20:59:05 +0200 In-Reply-To: <20060601154613.GC19388@surnet.cl> (Alvaro Herrera's message of "Thu, 1 Jun 2006 11:46:13 -0400") Message-ID: <87d5dsn1mu.fsf@mid.deneb.enyo.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/21 X-Sequence-Number: 25257 * Alvaro Herrera: > Miroslav ?ulc wrote: >> The GROUP BY is really fast :-) > > Doh! How does it do it? It uses a hash table and can therefore discard duplicate rows more quickly (essentially linear time in the number of rows if the number of different rows is bounded).