SELECT field1, field2
FROM table
WHERE id = 10
LIMIT 1
and id is a primary key, is the LIMIT 1 useful?
In other words, when searching a primary key index, does mysql automatically stop the search when it finds the first matching record even when you don’t use a LIMIT clause?
Thanks, I won’t bother using it then. As Guido suggested, I did try BENCHMARK a few times on a SELECT query both with and without LIMIT 1, and the execution times were very similar.
It knows from the fact you are referencing it using the primary key that you only want the one - the only effect the LIMIT would have is to make the code less portable if you ever needed to switch to a different database.