Re: timestamp and indexes

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Glen Parker <glenebob(at)nwlink(dot)com>
Cc: Pg-General <pgsql-general(at)postgresql(dot)org>
Subject: Re: timestamp and indexes
Date: 2002-01-23 01:10:58
Message-ID: 20020122170602.A10393-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 22 Jan 2002, Glen Parker wrote:

> Hi all,
>
> I seem to remember seeing something related to this on this list in the
> past, but I can't find it now. So I'll be brief for starters.
>
> I have a log table that's getting several thousand inserts per day, properly
> vacuumed/analysed at night, etc. A query like this:
> select * from log where date_log = now();
> refuses to use the index on date_log (the timestamp).
>
> explain says this:
> Seq Scan on log (cost=0.00..2053.26 rows=8 width=80)
>
> If I do 'set enable_seqscan to off', it still won't use the index.

It looks like now() is not cachable (at least in my 7.2beta4 pg_proc) so
it's not going to use the index. You might be able to fake things with
an iscachable function that just returns the now() value (like:
create function foonow() returns timestamp as
'select now();' language 'sql' with (iscachable);
)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Barry Lind 2002-01-23 01:54:16 Re: implemention of calls to stored procs.
Previous Message Nic Ferrier 2002-01-23 00:56:28 Re: implemention of calls to stored procs.