Indexscan is only used if we use "limit n" - Mailing list pgsql-performance

From Sebastián Baioni
Subject Indexscan is only used if we use "limit n"
Date
Msg-id 377451.48008.qm@web36104.mail.mud.yahoo.com
Whole thread Raw
Responses Re: Indexscan is only used if we use "limit n"  (Alvaro Herrera <alvherre@commandprompt.com>)
Re: Indexscan is only used if we use "limit n"  (joao <joao.junior@bra03034.conab.gov.br>)
Re: Indexscan is only used if we use "limit n"  (Mark Lewis <mark.lewis@mir3.com>)
Re: Indexscan is only used if we use "limit n"  (Josh Berkus <josh@agliodbs.com>)
List pgsql-performance
Hello,
Whe are running PostgreSQL 8.2.0 on amd64-portbld-freebsd6.2, compiled by GCC cc (GCC) 3.4.6 [FreeBSD] 20060305.
The query only uses the index if we have a "limit n":

Without "Limit n"
explain
select esapcuit, esapcuil
from esact00 t1
order by esapcuit, esapcuil

Sort  (cost=843833.82..853396.76 rows=3825177 width=30)
  Sort Key: esapcuit, esapcuil
  ->  Seq Scan on esact00 t1  (cost=0.00..111813.77 rows=3825177 width=30)

With "Limit n"
explain
select esapcuit, esapcuil
from esact00 t1
order by esapcuit, esapcuil
limit 1

Limit  (cost=0.00..1.86 rows=1 width=30)
  ->  Index Scan using uesact002 on esact00 t1  (cost=0.00..7129736.89 rows=3825177 width=30)

Our postgresql.conf is:
enable_bitmapscan = on
enable_hashagg = on
enable_hashjoin = on
enable_indexscan = on
enable_mergejoin = on
enable_nestloop = on
enable_seqscan = on
enable_sort = on
enable_tidscan = on

Thank you.
Sebastián


Sebastián Baioni



¡Sé un mejor ambientalista!
Encontrá consejos para cuidar el lugar donde vivimos..

pgsql-performance by date:

Previous
From: Decibel!
Date:
Subject: Re: RAID 10 or RAID 10 + RAID 1
Next
From: Alvaro Herrera
Date:
Subject: Re: Indexscan is only used if we use "limit n"