pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@commandprompt.com>
To: Sebastián Baioni <sebaioni-postgresql@yahoo.com.ar>
Cc: Performance PostgreSQL <pgsql-performance@postgresql.org>
Subject: Re: Indexscan is only used if we use "limit n"
Date: Wed, 15 Aug 2007 16:00:39 -0400
Message-ID: <20070815200039.GF25596@alvh.no-ip.org> (raw)
In-Reply-To: <377451.48008.qm@web36104.mail.mud.yahoo.com>
References: <377451.48008.qm@web36104.mail.mud.yahoo.com>

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"



view thread (5+ messages)  latest in thread

Message-ID: <20070815200039.GF25596@alvh.no-ip.org>
Permalink:  ../20070815200039.GF25596@alvh.no-ip.org/
Also on:    postgresql.org/message-id/20070815200039.GF25596@alvh.no-ip.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: alvherre@commandprompt.com, sebaioni-postgresql@yahoo.com.ar
  Subject: Re: Indexscan is only used if we use "limit n"
  In-Reply-To: <20070815200039.GF25596@alvh.no-ip.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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