Thread: INDEX PROBLEMS ?
On postgres 7.2.3 I have found what follows: explain select * from documents where iddoc>1; Seq Scan on lotti (cost=0.00..831.79 rows=26783 width=98) EXPLAIN explain select * from documents where iddoc=1; Index Scan using lotti_pkey on lotti (cost=0.00..2.26 rows=1 width=98) Why index is not used for operators > and < ???? Alex
Alex, > On postgres 7.2.3 I have found what follows: > > explain select * from documents where iddoc>1; > > Seq Scan on lotti (cost=0.00..831.79 rows=26783 width=98) > > EXPLAIN > explain select * from documents where iddoc=1; > > Index Scan using lotti_pkey on lotti (cost=0.00..2.26 rows=1 > width=98) > > Why index is not used for operators > and < ???? Because ">" is returning 26,000 rows. When you return that many rows, a Seq Scan is faster. -Josh