Re: Why don't use index on x when ORDER BY x, y?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Vlad Arkhipov <arhipov(at)dc(dot)baikal(dot)ru>
Cc: pgsql-performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Why don't use index on x when ORDER BY x, y?
Date: 2014-11-24 15:38:46
Message-ID: 23348.1416843526@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Vlad Arkhipov <arhipov(at)dc(dot)baikal(dot)ru> writes:
> I wonder why Postgres does not use index in the query below?

Because it's useless: you'd still have to do a sort, and an indexscan
is going to be a slower source of data for the sort than a seqscan.

There's been some experimentation of late with a "partial sort" capability
that could take advantage of partially-ordered input, which might make
this kind of thing interesting after all. But it's not committed and
might never be: it's far from clear that it'd be a win in many cases.

regards, tom lane

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Scott Marlowe 2014-11-25 20:36:03 Small performance regression in 9.2 has a big impact
Previous Message Robert Klemme 2014-11-24 13:39:11 Re: Why don't use index on x when ORDER BY x, y?