Re: Indexes slower when used in decending vs. ascending order? - Mailing list pgsql-novice

From Tom Lane
Subject Re: Indexes slower when used in decending vs. ascending order?
Date
Msg-id 9133.1144779487@sss.pgh.pa.us
Whole thread Raw
In response to Indexes slower when used in decending vs. ascending order?  (Alasdair Young <ayoung@vigilos.com>)
Responses Re: Indexes slower when used in decending vs. ascending
List pgsql-novice
Alasdair Young <ayoung@vigilos.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

pgsql-novice by date:

Previous
From: Alasdair Young
Date:
Subject: Indexes slower when used in decending vs. ascending order?
Next
From: Andre Majorel
Date:
Subject: Curses interface