X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AF13A5E46C0 for ; Mon, 16 Aug 2004 20:25:52 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 98932-05 for ; Mon, 16 Aug 2004 23:25:44 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id ADC945E3F15 for ; Mon, 16 Aug 2004 20:25:43 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7GNPf4a018545; Mon, 16 Aug 2004 19:25:42 -0400 (EDT) To: josh@agliodbs.com Cc: "Harmon S. Nine" , pgsql-performance@postgresql.org Subject: Re: Timestamp-based indexing In-reply-to: <200408161609.13018.josh@agliodbs.com> References: <410519F6.5020806@netarx.com> <200408161609.13018.josh@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Mon, 16 Aug 2004 16:09:13 -0700" Date: Mon, 16 Aug 2004 19:25:41 -0400 Message-ID: <18544.1092698741@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/251 X-Sequence-Number: 7887 Josh Berkus writes: >> monitor=# explain analyze select * from "eventtable" where timestamp > >> CURRENT_TIMESTAMP - INTERVAL '10 minutes'; > Hmmm. What verison of PostgreSQL are you running? I seem to remember an > issue in one version with selecting comparisons against now(). I'm also wondering about the exact datatype of the "timestamp" column. If it's timestamp without timezone, then the above is a cross-datatype comparison (timestamp vs timestamptz) and hence not indexable before 8.0. This could be fixed easily by using the right current-time function, viz LOCALTIMESTAMP not CURRENT_TIMESTAMP. (Consistency has obviously never been a high priority with the SQL committee :-(.) Less easily but possibly better in the long run, change the column type to timestamp with time zone. IMHO, columns representing definable real-world time instants should always be timestamptz, because the other way leaves you open to serious confusion about what the time value really means. regards, tom lane