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 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

[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