Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 776C34769AF for ; Mon, 24 Jun 2002 17:29:49 -0400 (EDT) Mailbox-Line: From sszabo@megazone23.bigpanda.com Mon Jun 24 17:29:49 2002 Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 3810A476C67 for ; Mon, 24 Jun 2002 14:36:58 -0400 (EDT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id EE973D602; Mon, 24 Jun 2002 11:36:56 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id DA3615C02; Mon, 24 Jun 2002 11:36:56 -0700 (PDT) Date: Mon, 24 Jun 2002 11:36:56 -0700 (PDT) From: Stephan Szabo To: Marcos Garcia Cc: pgsql-sql Subject: Re: Slow SELECT with distinct, in a TIMESTAMP type column In-Reply-To: <1024927121.1062.297.camel@sargao> Message-ID: <20020624113546.R56100-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-3.5 required=5.0 tests=IN_REP_TO,X_NOT_PRESENT,NO_MX_FOR_FROM version=2.30 X-Spam-Level: X-Archive-Number: 200206/328 X-Sequence-Number: 8293 On 24 Jun 2002, Marcos Garcia wrote: > The problem is that my query is too slow when i use distinct: > > pgsql> explain analyze SELECT distinct(smsdate) FROM send_total; > > NOTICE: QUERY PLAN: > > Unique (cost=15840.31..15870.81 rows=1220 width=8) (actual > time=56358.93..56452.78 rows=6670 loops=1) > -> Sort (cost=15840.31..15840.31 rows=12203 width=8) (actual > time=56358.91..56436.95 rows=12062 loops=1) > -> Seq Scan on send_total (cost=0.00..15012.03 rows=12203 > width=8) (actual time=0.55..56205.25 rows=12062 loops=1) > Total runtime: 56518.26 msec As a question, what does explain analyze show if you set enable_seqscan=off; first?