I have many queries I know should return 1 or 2 results. Should I explicitly LIMIT them or just let the DB do his job?
The scenario I mean is I am WHEREing on a unique combination of keys, OR when I might have the same result many times, just do LIMIT 1 instead of using DISTINCT…
I have many queries I know should return 1 or 2 results. Should I
Share
Generally speaking, you want to limit the number of rows accessed as a smaller result set runs faster.
An excerpt from SQL Server’s* Query Performance Tuning:
Alternatively, you can create a highly selective criteria:
*I know question is tagged as MySQL