Optimizing Existence Checks: Use SELECT 1 LIMIT 1 Instead of SELECT count(*)
Developers often use SELECT count(*) to check record existence, but replacing it with SELECT 1 … LIMIT 1 improves performance by stopping after the first match, allowing simpler Java null checks and potentially reducing index usage, especially when only a binary presence test is needed.
