Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id EB19C476247 for ; Mon, 24 Jun 2002 17:56:11 -0400 (EDT) Mailbox-Line: From sszabo@megazone23.bigpanda.com Mon Jun 24 17:56:11 2002 Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id D6418476394 for ; Mon, 24 Jun 2002 17:06:01 -0400 (EDT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 65950D602; Mon, 24 Jun 2002 14:06:00 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 38E855C02; Mon, 24 Jun 2002 14:06:00 -0700 (PDT) Date: Mon, 24 Jun 2002 14:06:00 -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: <1024947975.1035.648.camel@sargao> Message-ID: <20020624140056.B59376-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/327 X-Sequence-Number: 8292 On 24 Jun 2002, Marcos Garcia wrote: > > When i make the set enable_seqscan = off the result is: > > dbname=# set enable_seqscan = off; > SET VARIABLE > dbname=# explain analyze SELECT distinct(smsdate) FROM send_total; > > NOTICE: QUERY PLAN: > > Unique (cost=0.00..31084.39 rows=1232 width=8) (actual > time=108.60..195210.91 rows=6676 loops=1) > -> Index Scan using send_total_smsdate_idx on send_total > (cost=0.00..31053.60 rows=12315 width=8) (actual time=108.59..195145.43 > rows=12087 loops=1) > Total runtime: 195226.24 msec Well the plan choice makes sense (since it's about 3.5x faster as a sequence scan over the index scan). It looks like most of the time is taken up by the actual scan (is "select smsdate from send_total" pretty much as slow?).