BUG #2381: LIMIT 1 very very lazy than without - Mailing list pgsql-bugs

From Peter Krauss
Subject BUG #2381: LIMIT 1 very very lazy than without
Date
Msg-id 200604062250.k36MonFr099690@wwwmaster.postgresql.org
Whole thread Raw
List pgsql-bugs
The following bug has been logged online:

Bug reference:      2381
Logged by:          Peter Krauss
Email address:      krauss@i-node.com.br
PostgreSQL version: 7.4
Operating system:   Linux
Description:        LIMIT 1 very very lazy than without
Details:

The single query (on psql) is fary fast
(less than 1 sec)

 SELECT a,b,c,d FROM products_view WHERE
 sku='0-123-0-0-6024-20'
 OR lower(codfornecedor)=lower('0-123-0-0-6024-20')
 OR lower(eanfor)=lower('0-123-0-0-6024-20')
 OR lower(refprodfornecedor)=lower('0-123-0-0-6024-20');
 -- ~0.1 second

BUT, IF I ADD a "LIMIT 1", it consumes 2 minutes!

 SELECT a,b,c,d FROM products_view WHERE
 sku='0-123-0-0-6024-20'
 OR lower(codfornecedor)=lower('0-123-0-0-6024-20')
 OR lower(eanfor)=lower('0-123-0-0-6024-20')
 OR lower(refprodfornecedor)=lower('0-123-0-0-6024-20')
 LIMIT 1;
-- ~ 2 minutes !!

pgsql-bugs by date:

Previous
From: "Magnus Hagander"
Date:
Subject: Re: Bug in window xp
Next
From: Tom Lane
Date:
Subject: Re: Bug in window xp