From: | "Jackson, DeJuan" <djackson(at)cpsgroup(dot)com> |
---|---|
To: | Andrew Merrill <andrew(at)compclass(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>, "Jackson, DeJuan" <djackson(at)cpsgroup(dot)com>, pgsql-sql(at)hub(dot)org, PGSQL Hackers <pgsql-hackers(at)hub(dot)org> |
Subject: | RE: [SQL] indexing a datetime by date |
Date: | 1999-03-30 17:33:46 |
Message-ID: | D05EF808F2DFD211AE4A00105AA1B5D2037A39@cpsmail |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-sql |
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
>
From | Date | Subject | |
---|---|---|---|
Next Message | The Hermit Hacker | 1999-03-30 17:38:21 | Re: [HACKERS] vacuum updated... |
Previous Message | Andrew Merrill | 1999-03-30 17:25:39 | Re: [SQL] indexing a datetime by date |
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Merrill | 1999-03-30 17:44:09 | regexp strangeness |
Previous Message | Andrew Merrill | 1999-03-30 17:25:39 | Re: [SQL] indexing a datetime by date |