Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 66ECA9FB508 for ; Tue, 8 May 2007 17:28:26 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 21533-08 for ; Tue, 8 May 2007 17:28:23 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from exchange.g2switchworks.com (mail.g2switchworks.com [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id 68C729FB63D for ; Tue, 8 May 2007 17:28:23 -0300 (ADT) Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; Tue, 8 May 2007 20:28:22 +0000 Received: from state.g2switchworks.com by mail.g2switchworks.com; 08 May 2007 15:28:22 -0500 Subject: Re: DISTINCT Question From: Scott Marlowe To: Y Sidhu Cc: pgsql-performance@postgresql.org In-Reply-To: References: Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1178656101.7497.29.camel@state.g2switchworks.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Tue, 08 May 2007 15:28:22 -0500 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/137 X-Sequence-Number: 24527 On Tue, 2007-05-08 at 14:52, Y Sidhu wrote: > Does using DISTINCT in a query force PG to abandon any index search it > might have embarked upon? explain analyze select distinct request from businessrequestsummary where lastflushtime between now() - interval '30 minutes' and now(); QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Unique (cost=3.04..3.04 rows=1 width=17) (actual time=110.565..162.630 rows=75 loops=1) -> Sort (cost=3.04..3.04 rows=1 width=17) (actual time=110.555..135.252 rows=6803 loops=1) Sort Key: request -> Index Scan using businessrequestsummary_lastflushtime_dx on businessrequestsummary (cost=0.01..3.03 rows=1 width=17) (actual time=0.063..59.674 rows=6803 loops=1) Index Cond: ((lastflushtime >= (now() - '00:30:00'::interval)) AND (lastflushtime <= now())) Total runtime: 163.925 ms (6 rows) I'd say no.