index on id and created_at - Mailing list pgsql-general

From Marcus Engene
Subject index on id and created_at
Date
Msg-id 48C9426F.4090003@engene.se
Whole thread Raw
Responses Re: index on id and created_at  ("Scott Marlowe" <scott.marlowe@gmail.com>)
Re: index on id and created_at  (hubert depesz lubaczewski <depesz@depesz.com>)
List 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


pgsql-general by date:

Previous
From: johnf
Date:
Subject: Re: keep alive losing connections
Next
From: "Scott Marlowe"
Date:
Subject: Re: keep alive losing connections