Re: Indexes

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Primoz <primoz(at)slo-tech(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Indexes
Date: 2004-08-20 03:16:32
Message-ID: 15516.1092971792@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Primoz <primoz(at)slo-tech(dot)com> writes:
> is there any way to speedup queryes like

> select ... from [table a] where [int field b] = [number] order by [datetime
> field c] desc limit [number];

For reasonably-small values of the LIMIT, what you want is
(a) a two-column index on (b,c)
(b) change the ORDER BY to
ORDER BY b DESC, c DESC

See the pgsql-performance archives for more discussion.

regards, tom lane

In response to

  • Indexes at 2004-08-20 03:31:36 from Primoz

Browse pgsql-general by date

  From Date Subject
Next Message Primoz 2004-08-20 03:31:36 Indexes
Previous Message Tom Lane 2004-08-20 01:25:22 Re: 8.0 release schedule?