pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Richards <miker@scifair.acadiau.ca>
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] indexes using datetime
Date: Sat, 28 Aug 1999 20:46:40 -0400
Message-ID: <9681.935887600@sss.pgh.pa.us> (raw)
In-Reply-To: <Pine.BSF.4.10.9908271904550.29442-100000@scifair.acadiau.ca>

Michael Richards <miker@scifair.acadiau.ca> writes:
> explain select * from logins where logintime>'now'::datetime-'40
> days'::timespan;
> NOTICE:  QUERY PLAN:
> Seq Scan on logins  (cost=5839.78 rows=44958 width=44)

> Very bad query plan :(

Yah.  It's got nothing to do with datetime though.  Problem is that the
system can only make indexscans work with WHERE clauses of the form
"field op constant" (for "op"s related to the sort ordering of the
index of course).  Your righthand side is not a constant.

Eventually, maybe for 6.6 or 6.7, we will have the smarts in place to
reduce constant expressions to simple constants during preprocessing of
a query.  For now, you are going to have to structure your application to
precompute the value that's going to be compared against index entries.

			regards, tom lane



view thread (3+ messages)  latest in thread

Message-ID: <9681.935887600@sss.pgh.pa.us>
Permalink:  ../9681.935887600@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/9681.935887600@sss.pgh.pa.us

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, miker@scifair.acadiau.ca
  Subject: Re: [SQL] indexes using datetime
  In-Reply-To: <9681.935887600@sss.pgh.pa.us>
  References: <Pine.BSF.4.10.9908271904550.29442-100000@scifair.acadiau.ca> <9681.935887600@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