Bird
0
0

A B-tree index was created on column age, but a query with WHERE age + 1 = 30 is slow. Why?

medium📝 Debug Q7 of 15
SQL - Indexes and Query Performance
A B-tree index was created on column age, but a query with WHERE age + 1 = 30 is slow. Why?
AThe database ignores indexes on numeric columns.
BThe expression prevents the index from being used.
CThe query syntax is invalid.
DThe index is corrupted and needs rebuilding.
Step-by-Step Solution
Solution:
  1. Step 1: Understand index usage with expressions

    Using arithmetic expressions on indexed columns disables index usage.
  2. Step 2: Check other options

    No evidence of corruption; query syntax is valid; numeric columns support indexes.
  3. Final Answer:

    The expression prevents the index from being used. -> Option B
  4. Quick Check:

    Expressions on indexed columns block index use [OK]
Quick Trick: Avoid expressions on indexed columns to keep index use [OK]
Common Mistakes:
  • Assuming index corruption without proof
  • Thinking query syntax is wrong
  • Believing numeric columns can't be indexed

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes