Re: Indexscan is only used if we use "limit n"

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Sebastián Baioni <sebaioni-postgresql(at)yahoo(dot)com(dot)ar>
Cc: Performance PostgreSQL <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Indexscan is only used if we use "limit n"
Date: 2007-08-15 20:00:39
Message-ID: 20070815200039.GF25596@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Sebastián Baioni escribió:
> 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)

That's right. What else did you expect? It estimates it has to return
3 million rows after all -- using an indexscan would be slow.

--
Alvaro Herrera http://www.amazon.com/gp/registry/DXLWNGRJD34J
"Puedes vivir solo una vez, pero si lo haces bien, una vez es suficiente"

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message joao 2007-08-15 20:02:43 Re: Indexscan is only used if we use "limit n"
Previous Message Sebastián Baioni 2007-08-15 19:36:45 Indexscan is only used if we use "limit n"