pg.ddx.io pgsql-sql@postgresql.org mailing list archivehelp / color / mirror / Atom feed
From: Jackson, DeJuan <djackson@cpsgroup.com>
To: Andrew Merrill <andrew@compclass.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Thomas Lockhart <lockhart@alumni.caltech.edu>
Cc: Jackson, DeJuan <djackson@cpsgroup.com>
Cc: pgsql-sql@hub.org, PGSQL Hackers <pgsql-hackers@hub.org>
Subject: RE: [SQL] indexing a datetime by date
Date: Tue, 30 Mar 1999 11:33:46 -0600
Message-ID: <D05EF808F2DFD211AE4A00105AA1B5D2037A39@cpsmail> (raw)
try:
explain select when from notes where datetime_date(when) = 'now'::date;
-DEJ
> Tom Lane wrote:
>
> > In the meantime, a workaround is to call the function using its
> > builtin name:
> >
> > play=> create table notes (when datetime);
> > CREATE
> > play=> create index when_ndx3 on notes (datetime_date(when)
> date_ops);
> > CREATE
>
> Thanks, that helps - I can now index a datetime field by
> date.But the index
> doesn't appear to be used:
>
> db=> create index ndx3 on notes (datetime_date(when) date_ops);
> CREATE
> db=> vacuum analyze notes;
> VACUUM
> db=> explain select when from notes where when::date = 'now'::date;
> NOTICE: QUERY PLAN:
>
> Seq Scan on notes (cost=4330.37 size=43839 width=8)
>
> EXPLAIN
>
> So it appears that the optimizer doesn't like this index.
> (This is with
> version 6.4.2.)
> The table has about 90,000 rows, of which between 10 and 100
> might match a
> given date, so an index would really help.
>
> Am I missing something simple here? Thanks again for all your help.
>
> Andrew Merrill
>
view thread (9+ messages) latest in thread
Message-ID: <D05EF808F2DFD211AE4A00105AA1B5D2037A39@cpsmail> Permalink: ../D05EF808F2DFD211AE4A00105AA1B5D2037A39@cpsmail/ Also on: postgresql.org/message-id/D05EF808F2DFD211AE4A00105AA1B5D2037A39@cpsmail ·
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: djackson@cpsgroup.com, andrew@compclass.com, tgl@sss.pgh.pa.us, lockhart@alumni.caltech.edu, pgsql-hackers@hub.org Subject: Re: [SQL] indexing a datetime by date In-Reply-To: <D05EF808F2DFD211AE4A00105AA1B5D2037A39@cpsmail> References: <D05EF808F2DFD211AE4A00105AA1B5D2037A39@cpsmail> * 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