Re: index being ignored for "limit n" queries

From: Piotr Sulecki <Piotr(dot)Sulecki(at)sybilla(dot)traxelektronik(dot)pl>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general(at)postgresql(dot)org
Subject: Re: index being ignored for "limit n" queries
Date: 2005-08-10 06:44:43
Message-ID: 42F9A25B.5070907@sybilla.traxelektronik.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ave!

Tom Lane wrote:
>>trax=# explain select * from pakiety where stid = 234::smallint order by
>>received desc limit 1;
>
> The reason this won't use the (stid, received) index is that the
> requested sort order doesn't match that index. Try
>
> select * from pakiety where stid = 234::smallint
> order by stid desc, received desc
> limit 1;

Thanks. It works. And the speedup was from 2 minutes 32.13 seconds to
0.69 seconds (in a worst case for the previous scenario).

Thanks again for your help.

Piotr Sulecki.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Flix Beltrn 2005-08-10 07:47:43 Change to PostgreSQL
Previous Message Roman Neuhauser 2005-08-10 05:50:07 Re: Error Loading postgresql