X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AF32C567F7 for ; Wed, 16 Mar 2005 18:11:25 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 79620-10 for ; Wed, 16 Mar 2005 18:11:17 +0000 (GMT) Received: from tht.net (vista.tht.net [216.126.88.2]) by svr1.postgresql.org (Postfix) with ESMTP id 1F3AF567F0 for ; Wed, 16 Mar 2005 18:11:14 +0000 (GMT) Received: from dyn-70-66.tor.dsl.tht.net (dyn-70-66.tor.dsl.tht.net [134.22.70.66]) by tht.net (Postfix) with ESMTP id 1526A76A5C; Wed, 16 Mar 2005 13:11:14 -0500 (EST) Subject: Re: Speeding up select distinct From: Rod Taylor To: Laurent Martelli Cc: pgsql-performance@postgresql.org In-Reply-To: <87k6o74gms.fsf@stan.aopsys> References: <87k6o74gms.fsf@stan.aopsys> Content-Type: text/plain Date: Wed, 16 Mar 2005 13:10:23 -0500 Message-Id: <1110996623.1132.244.camel@home> Mime-Version: 1.0 X-Mailer: Evolution 2.2.0 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.012 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/333 X-Sequence-Number: 11038 On Wed, 2005-03-16 at 18:58 +0100, Laurent Martelli wrote: > Consider this query: > > SELECT distinct owner from pictures; The performance has nothing to do with the number of rows returned, but rather the complexity of calculations and amount of data to sift through in order to find it. > Any ideas, apart from more or less manually maintaining a list of > distinct owners in another table ? This would be the proper thing to do, along with adding a foreign key from pictures to the new owner structure for integrity enforcement. --