Problem using LIMIT 1 when only 1 record exists. - Mailing list pgsql-bugs

From Steve Thames
Subject Problem using LIMIT 1 when only 1 record exists.
Date
Msg-id AHEHICJPCIJDKAMKKIHBKELICNAA.steve@softlife.com
Whole thread Raw
Responses Re: Problem using LIMIT 1 when only 1 record exists.
List pgsql-bugs
I have a table with 14,655,100 rows in it.  No unique keys.
I have an index on the fields "symbol", varchar[12], and "qdate", int4 as
format=YYYYMMDD.
I have a field called "expmoyr", char[6] as format=Mmm-YY.
I have a field called "last", float4.

The SQL command:
SELECT last FROM table WHERE symbol='Symbol' AND expmoyr='Mmm-YY' ORDER BY
qdate DESC LIMIT 1;

This query works fine when there is more than one record meeting the
criteria.  When there is only 1, the query locks and no result is returned.

I have tried vacuuming and reindexing the entire database several times.
Please let me know if there is a fix to this.

Thanks.
Steve Thames
Softlife Consulting, Inc.
530-672-6908
www.softlife.com

pgsql-bugs by date:

Previous
From: Javier Carlos
Date:
Subject: Re: SELECT with MANY tables
Next
From: Mark Iszler
Date:
Subject: Problem with building PostgreSQL 7.4 from source