Re: Indexes slower when used in decending vs. ascending order?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alasdair Young <ayoung(at)vigilos(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Indexes slower when used in decending vs. ascending order?
Date: 2006-04-11 18:18:07
Message-ID: 9133.1144779487@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Alasdair Young <ayoung(at)vigilos(dot)com> writes:
> I am noticing a significant speed difference between the following two
> queries (the one using "ORDER BY clientkey desc, premiseskey desc,
> logtime desc, logkey desc" takes 19 seconds to execute, versus almost
> immediate execution of the "ORDER BY clientkey, premiseskey, logtime,
> logkey") and was wondering if there was anything I could do to make
> execution any faster.

I'd bet that the problem is the "filter" on logicaldel --- is the value
of that heavily correlated with the index ordering? You could be
scanning through many many rows of the index to reach the first (last)
one with logicaldel = 'N'.

regards, tom lane

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Andre Majorel 2006-04-11 18:58:07 Curses interface
Previous Message Alasdair Young 2006-04-11 18:06:16 Indexes slower when used in decending vs. ascending order?