Re: BUG #3824: Query hangs when result set empty using sort and limit

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Gregor Roessle" <g(dot)roessle(at)osram(dot)de>, <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #3824: Query hangs when result set empty using sort and limit
Date: 2007-12-18 17:38:56
Message-ID: 87prx33ntb.fsf@oxford.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:

> "Gregor Roessle" <g(dot)roessle(at)osram(dot)de> writes:
>> The Server hangs when executing a query like this:
>
>> select * from messwerte where pknr = 28315178 and isproducing = 't' order by
>> timestamp desc limit 1;
>
> I seriously doubt that it's hung. Takes a long time, maybe so. Is it
> trying to use an indexscan on timestamp to substitute for a sort step?

Surely it wouldn't make 32ms become long enough to qualify as "hung".

Unless perhaps it's otherwise using an index on pknr and/or isproducing and
with the "ORDER BY timestamp desc LIMIT 1" it's using a different large index.

I think we have to see

EXPLAIN ANALYZE select * from messwerte where pknr = 28315178 and isproducing = 't' order by timestamp;
EXPLAIN ANALYZE select * from messwerte where pknr = 28315178 and isproducing = 't' limit 1;
EXPLAIN select * from messwerte where pknr = 28315178 and isproducing = 't' order by timestamp limit 1;

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Ask me about EnterpriseDB's On-Demand Production Tuning

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Gregory Stark 2007-12-18 17:42:42 Re: Bug (#3484) - Invalid page header again
Previous Message Zdenek Kotala 2007-12-18 16:30:09 Re: Bug (#3484) - Invalid page header again