Search Postgresql Archives

index on id and created_at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux