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 412C9D1E89D for ; Fri, 23 Jan 2004 07:50:38 +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 21876-02 for ; Fri, 23 Jan 2004 03:50:08 -0400 (AST) Received: from smtp08.retemail.es (smtp08.auna.com [62.81.186.18]) by svr1.postgresql.org (Postfix) with ESMTP id 5F293D1E89F for ; Fri, 23 Jan 2004 03:50:02 -0400 (AST) Received: from ariel ([62.57.108.228]) by smtp08.retemail.es (InterMail vM.5.01.05.32 201-253-122-126-132-20030307) with SMTP id <20040123075003.FZQK9384.smtp08.retemail.es@ariel> for ; Fri, 23 Jan 2004 08:50:03 +0100 Message-ID: <009b01c3e185$8255d8f0$3c0aa8c0@iberica.andromeiberica.com> From: "Arnau Rebassa i Villalonga" To: Subject: Queries with timestamp, 2 Date: Fri, 23 Jan 2004 08:50:02 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=BAYES_30, UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200401/338 X-Sequence-Number: 5512 Hi all, First of all thanks to Josh and Richard for their replies. What I have done to test their indications is the following. I have created a new table identical to STATISTICS, and an index over the TIMESTAMP_IN field. CREATE TABLE STATISTICS2 ( STATISTIC_ID NUMERIC(10) NOT NULL DEFAULT NEXTVAL('STATISTIC_ID_SEQ') CONSTRAINT pk_st_statistic2_id PRIMARY KEY, TIMESTAMP_IN TIMESTAMP, VALUE NUMERIC(10) ); CREATE INDEX i_stats2_tin ON STATISTICS2(TIMESTAMP_IN); After that I inserted the data from STATISTICS and vacuumed the DB: INSERT INTO STATISTICS2 ( SELECT * FROM STATISTICS ); vacuumdb -f -z -d test once the vacuum has finished I do the following query 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? Thank you very much -- Arnau