Bird
0
0

A developer writes this query:

medium📝 Debug Q7 of 15
SQL - Indexes and Query Performance
A developer writes this query:
UPDATE customers SET email = 'new@example.com' WHERE id = 123;
The email column has an index. The update is very slow. What could be wrong?
AThe query syntax is invalid and causes a runtime error.
BThe index on <code>email</code> must be updated, causing overhead.
CThe <code>WHERE</code> clause is missing, so all rows are updated.
DThe <code>email</code> column cannot be updated if indexed.
Step-by-Step Solution
Solution:
  1. Step 1: Identify the indexed column being updated

    The email column is indexed and is being updated.
  2. Step 2: Understand the impact of updating an indexed column

    Updating an indexed column requires updating the index, which adds overhead and slows the query.
  3. Final Answer:

    The index on email must be updated, causing overhead. -> Option B
  4. Quick Check:

    Index update overhead = slow UPDATE [OK]
Quick Trick: Updating indexed columns adds overhead, slowing queries [OK]
Common Mistakes:
  • Assuming syntax error causes slowness
  • Believing indexed columns cannot be updated
  • Ignoring index update cost

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes