index on id and created_at

Поиск
Список
Период
Сортировка
От Marcus Engene
Тема index on id and created_at
Дата
Msg-id 48C9426F.4090003@engene.se
обсуждение исходный текст
Ответы 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>)
Список 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 по дате отправления:

Предыдущее
От: johnf
Дата:
Сообщение: Re: keep alive losing connections
Следующее
От: "Scott Marlowe"
Дата:
Сообщение: Re: keep alive losing connections