index on id and created_at

From: Marcus Engene <mengpg2(at)engene(dot)se>
To: POSTGRESQL <pgsql-general(at)postgresql(dot)org>
Subject: index on id and created_at
Date: 2008-09-11 16:08:15
Message-ID: 48C9426F.4090003@engene.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

If I have a table like...

CREATE TABLE apa
(
objectid SERIAL PRIMARY KEY NOT NULL
,created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL
,somedata text
)
WITHOUT OIDS;

...where if rowX har higher objectid than rowY, it is implied that rowX
has a later created_at then rowY.

select
objectid
from
apa
where
created_at > now() - interval '1 day'
order by
objectid desc;

In this select, it would have been nice to dodge the full table scan
without adding an index to created_at. Is this possible somehow?

Best regards,
Marcus

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2008-09-11 16:13:14 Re: keep alive losing connections
Previous Message johnf 2008-09-11 16:07:34 keep alive losing connections