Indexing Anti-Patterns & Pitfalls
Avoid common indexing mistakes - over-indexing, write-throughput penalties, and function wrapping that disables indexes.
Indexing Anti-Patterns & Pitfalls is an essential topic in SQL and relational database engineering.
Overview
Building on foundational principles introduced in explain-query-plans, mastering indexing anti-patterns & pitfalls provides the core mental model and practical query skills needed for production relational database engineering.
-- WRONG: Wrapping column in function disables standard index!
-- WHERE YEAR(created_at) = 2025
-- CORRECT: Range query utilizes index on created_at!
SELECT * FROM orders WHERE created_at >= '2025-01-01' AND created_at < '2026-01-01';
Key Concepts
- Understand the fundamental syntax, conventions, and mental model.
- Avoid common beginner traps, data type mismatches, and performance pitfalls.
- Apply practical idioms directly in production applications.
[!TIP] Master this concept to build a rock-solid foundation. Next, proceed to acid-properties.