Re: [SQL] Index lookup on > and < criteria

2005-11-02 Thread David Durham
Yeah, analyze did make a difference. See below. -- Index Scan using october_begin_time on october_cdr_call (cost=0.00..98383.82 r ows=24594 width=568) (actual time=0.280..79274.579 rows=538592 loops=1) Index Cond: ((beg

Re: [SQL] Index lookup on > and < criteria

2005-11-01 Thread Michael Fuhr
On Tue, Nov 01, 2005 at 03:21:21PM -0600, David Durham wrote: > sipcdr=# explain analyze select * from october_cdr_call where begin_time > >= '10/1/2005' and begin_time < '10/4/2005'; > > QUERY PLAN > > >

Re: [SQL] Index lookup on > and < criteria

2005-11-01 Thread David Durham
Michael Fuhr wrote: No need to guess: run the queries with enable_seqscan disabled and see if an index scan is indeed faster. select max(myTimeStamp) from myTable; In current releases min() and max() can't use indexes; search the archives for numerous discussions of the reasons. The work

Re: [SQL] Index lookup on > and < criteria

2005-11-01 Thread Michael Fuhr
On Tue, Nov 01, 2005 at 12:18:19PM -0600, David Durham wrote: > 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 '<' oper

Re: [SQL] Index lookup on > and < criteria

2005-11-01 Thread A. Kretschmer
am 01.11.2005, um 12:18:19 -0600 mailte David Durham folgendes: > 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 '<' o

[SQL] Index lookup on > and < criteria

2005-11-01 Thread David Durham
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 row