pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
INDEX PROBLEMS ?
2+ messages / 2 participants
[nested] [flat]

* INDEX PROBLEMS ?
@ 2002-11-16 18:04 PostgreSQL Server <postgres@rsd.it>
  2002-11-16 19:06 ` Re: INDEX PROBLEMS ? Josh Berkus <josh@agliodbs.com>
  0 siblings, 1 reply; 2+ messages in thread

From: PostgreSQL Server @ 2002-11-16 18:04 UTC (permalink / raw)
  To: pgsql-sql


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









^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: INDEX PROBLEMS ?
  2002-11-16 18:04 INDEX PROBLEMS ? PostgreSQL Server <postgres@rsd.it>
@ 2002-11-16 19:06 ` Josh Berkus <josh@agliodbs.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Josh Berkus @ 2002-11-16 19:06 UTC (permalink / raw)
  To: PostgreSQL Server <postgres@rsd.it>; pgsql-sql

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





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2002-11-16 19:06 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-11-16 18:04 INDEX PROBLEMS ? PostgreSQL Server <postgres@rsd.it>
2002-11-16 19:06 ` Josh Berkus <josh@agliodbs.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox