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