X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 84D43D1D2C7 for ; Mon, 26 Jan 2004 14:38:30 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 79467-03 for ; Mon, 26 Jan 2004 10:38:03 -0400 (AST) Received: from frodo.hserus.net (frodo.hserus.net [204.74.68.40]) by svr1.postgresql.org (Postfix) with ESMTP id 324AFD1CAF6 for ; Mon, 26 Jan 2004 10:37:59 -0400 (AST) Received: from concord.pspl.co.in ([202.54.11.72]:64151 helo=frodo.hserus.net) by frodo.hserus.net with asmtp (Cipher TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.30 #0) id 1Al7sI-000F1M-6Z by authid with plain for ; Mon, 26 Jan 2004 20:08:02 +0530 Message-ID: <40152655.6080605@frodo.hserus.net> Date: Mon, 26 Jan 2004 20:08:13 +0530 From: Shridhar Daithankar User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Queries with timestamp II References: <049101c3e416$74023120$3c0aa8c0@iberica.andromeiberica.com> In-Reply-To: <049101c3e416$74023120$3c0aa8c0@iberica.andromeiberica.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/340 X-Sequence-Number: 5514 Arnau wrote: > explain analyze select * from statistics2 where timestamp_in < > to_timestamp( '20031201', 'YYYYMMDD' ); > NOTICE: QUERY PLAN: > > Seq Scan on statistics2 (cost=0.00..638.00 rows=9289 width=35) (actual > time=0.41..688.34 rows=27867 loops=1) > Total runtime: 730.82 msec > > That query is not using the index. Anybody knows what I'm doing wrong? Since it expects large number of rows will be returned, it is favouring sequential scan. Given how the estimates have differed, i.e. estimated 9289 v/s actual 27867, I sugest you up the statistics for the table using alter table. Check http://www.postgresql.org/docs/current/static/sql-altertable.html HTH Shridhar