Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-general by date

Next:From: PrimozDate: 2004-08-20 03:31:36
Subject: Indexes
Previous:From: Tom LaneDate: 2004-08-20 01:25:22
Subject: Re: 8.0 release schedule?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group