Не пойму логики в простейшем случае.
Есть таблица
CREATE TABLE log
(
ip inet NOT NULL,
regdt timestamp NOT NULL DEFAULT now()
)
CREATE INDEX ix_log_ip
ON log
USING btree
(ip, regdt);
Делаю explain запроса
select count(*) from log
where ip='127.0.0.1' and regdt>cast (now() as timestamp);
Использует индекс ix_log_ip
но стоит изменить так
select count(*) from log
where ip='127.0.0.1'
and regdt>cast (now()-interval '1 day' as timestamp);
как получаю sec scan
тоже самое если использовать cast('20080101' as timestamp).
Как побороть?
On Sat, 31 May 2008 11:38:53 +0600
apm wrote:
>как получаю sec scan
>тоже самое если использовать cast('20080101' as timestamp).
>
>Как побороть?
set enable_seqscan to off, но не думаю, что вы будете этому рады.
--
np: Dream Theater - Voices