Re: Indexing question
От | Tom Lane |
---|---|
Тема | Re: Indexing question |
Дата | |
Msg-id | 4119.1087757106@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Indexing question (Stan Bielski <bielski@ece.cmu.edu>) |
Список | pgsql-performance |
Stan Bielski <bielski@ece.cmu.edu> writes: > Table "public.allflow_tv_mydoom" > Column | Type | Modifiers > ------------+---------+----------- > tv_s | bigint | ^^^^^^ > Indexes: allflow_tv_mydoom_x btree (tv_s) > standb=# explain select * from allflow_tv_mydoom where tv_s < 1074200099 > and tv_s > 107506499; > [ gives seqscan ] This is a FAQ :-(. Unadorned integer constants are taken to be int4 not int8 (unless they are too large for int4), and cross-data-type comparisons are not indexable in existing releases. So you have to explicitly cast the comparison values to int8: explain select * from allflow_tv_mydoom where tv_s < 1074200099::bigint and tv_s > 107506499::bigint; (or use the standard CAST syntax if you prefer). 7.5 will have a fix for this ancient annoyance. BTW, is there a reason to be using tv_s+tv_us and not just a single timestamptz column? regards, tom lane
В списке pgsql-performance по дате отправления: