Index lookup on > and < criteria

Поиск
Список
Период
Сортировка
От David Durham
Тема Index lookup on > and < criteria
Дата
Msg-id 4367B16B.2050003@vailsys.com
обсуждение исходный текст
Ответы Re: Index lookup on > and < criteria  ("A. Kretschmer" <andreas.kretschmer@schollglas.com>)
Re: Index lookup on > and < criteria  (Michael Fuhr <mike@fuhr.org>)
Список pgsql-sql
Apologies if this questions is asked often.  I'm doing some select 
statements based on a timestamp field.  I have an index on the field, 
and when I use the '=' operator the index is used.  However, if I use 
the '>' or '<' operators, then it does a full table scan.  I've got 
around 6 million rows, so I would think that an index scan would be more 
appropriate.


Here are the statements I'm looking at:
   select * from myTable where myTimeStamp = '10/1/2005';

uses an index.
   select max(myTimeStamp) from myTable;   select * from myTable where myTimeStamp < '10/2/2005';   select * from
myTablewhere myTimeStamp < '10/2/2005' and myTimeStamp       >= '10/1/2005';
 

do not use indexes.  Can anyone point me to some info about what's going 
on?  I've started reading through the manual (chapter 13) which I think 
explains query optimizing, index usage etc.  It seems like this would be 
a common enough problem that it would have a relatively simple solution.  Thanks.


-Dave






В списке pgsql-sql по дате отправления:

Предыдущее
От: "Jim C. Nasby"
Дата:
Сообщение: Re: [GENERAL] A Not Join
Следующее
От: "A. Kretschmer"
Дата:
Сообщение: Re: Index lookup on > and < criteria