What are common SQL anti-patterns to avoid?

Why Interviewers Ask This

Senior MySQL / SQL engineers are expected to reason about architecture, performance, and edge cases. This question separates mid-level from senior candidates by testing deep system-level understanding.

Answer

Common SQL anti-patterns that cause performance, correctness, or maintainability problems: (1) SELECT *: fetches unused columns, prevents covering indexes, breaks code when columns are added/removed; (2) N+1 queries: one query to get N records then N queries for related data — use JOINs or eager loading; (3) No indexes on foreign keys: every JOIN becomes slow; (4) Functions on indexed columns in WHERE: WHERE YEAR(date) = 2024 defeats the index — rewrite as range; (5) Leading wildcard LIKE: WHERE name LIKE "%smith" — full table scan; (6) Storing comma-separated values in one column: violates 1NF, makes querying and joining impossible; (7) Not using transactions for multi-step operations; (8) Using OFFSET for deep pagination: OFFSET 10000 scans and discards 10,000 rows — use keyset pagination; (9) COUNT(*) without LIMIT on large tables; (10) Blind DELETE without transaction and test SELECT first; (11) Ignoring NULL semantics: comparing with = NULL instead of IS NULL; (12) Magic numbers: WHERE status = 1 — use meaningful values or ENUMs; (13) varchar for numbers or dates: prevents proper sorting and comparison; (14) Not normalizing at all (or over-normalizing for analytics).

Common Mistake

Don't just define the term — demonstrate that you understand when to use it and when not to. Showing awareness of trade-offs is what separates average from strong MySQL / SQL candidates.