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 !!