Although it's not typical, there are times when I find the use of a limit, without the use of ORDER BY to be very useful--
If you're attempting to get the field that will be returned by a query (typically because of stuff like 'SELECT * FROM table'), adding a limit is useful, but you can also just throw in 'WHERE 0=1'.
If you're attempting to clear a queue of some sort, where it doesn't need to be FIFO or otherwise processed in some particular order, but you can't have it run for too long. (so you can work in 500 record sets, rather than working on the whole queue at once) I found this very useful in Oracle, when I'd have to limit my processing time for each transaction so I didn't exceed my rollback segments as the system tried to maintain transactional consistency. (and unfortunately, due to the nature of the problem, I couldn't just set the transaction SERIALIZABLE ... I might've been able to use a autonomous transaction, though)
So, in most situations, I agree that it doesn't make sense, but there are times when it does, and it probably has more to do with how the programmer thinks about the problem more than anything else -- there are other working solutions for the examples that I've given above, but using limits without ordering in those situations makes sense to me.
In reply to Re^4: SQL::Statement limit clause with placeholders
by jhourcle
in thread SQL::Statement limit clause with placeholders
by springm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |