From: Tom Lane <tgl@sss.pgh.pa.us>
To: josh@agliodbs.com
Cc: Harmon S. Nine <hnine@netarx.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Timestamp-based indexing
Date: Mon, 16 Aug 2004 19:25:41 -0400
Message-ID: <18544.1092698741@sss.pgh.pa.us> (raw)
In-Reply-To: <200408161609.13018.josh@agliodbs.com>
References: <410519F6.5020806@netarx.com>
<200408161609.13018.josh@agliodbs.com>
Josh Berkus <josh@agliodbs.com> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: tgl@sss.pgh.pa.us, josh@agliodbs.com, hnine@netarx.com
Subject: Re: Timestamp-based indexing
In-Reply-To: <18544.1092698741@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox