Bug #5238 select count(*) ..... limit N
Submitted: 26 Aug 2004 19:13 Modified: 2 Feb 2006 15:56
Reporter: Devananda v Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server Severity:S4 (Feature request)
Version:4.1* OS:Any (any)
Assigned to: CPU Architecture:Any

[26 Aug 2004 19:13] Devananda v
Description:
Select * from tablename where a=b limit N 
vs
Select count(*) from tablename where a=b limit N

If the subset a=b may be very large, and I am only interested if it is above a certain threshhold, I would like the query "Select count(*) from tablename where a=b" to not have to count the entire subset - it would be sufficient if it returned "limit reached", or something to indicate that.

How to repeat:
not applicable

Suggested fix:
Allow a query to limit the number of items included in a call to "select count", so that if the dataset is far larger than the 'interested threshhold', the query does not take inordinately long, but instead returns and states that the threshhold was reached but that there is still more data in the dataset.
[26 Aug 2004 19:14] Devananda v
(changed title from limit 1000 to limit N)
[2 Feb 2006 15:56] Valeriy Kravchuk
Thank you for a feature request. Sorry, but I do not think it really needed. Just add proper index.