Bird
0
0

You have a table products with an index on price. You run this query:

medium📝 Debug Q6 of 15
SQL - Indexes and Query Performance
You have a table products with an index on price. You run this query:
UPDATE products SET price = price * 1.1;
but it runs very slowly. What is the most likely cause?
AThe index on <code>price</code> must be updated for every row, slowing the update.
BThe query syntax is incorrect and causes a full table scan.
CThe index on <code>price</code> speeds up the update, so slowness is unrelated.
DThe database ignores indexes on UPDATE, so the index has no effect.
Step-by-Step Solution
Solution:
  1. Step 1: Recognize that updating an indexed column affects the index

    Since price is indexed and updated for every row, the index must be updated repeatedly.
  2. Step 2: Understand the performance impact

    Updating the index for many rows causes significant overhead, slowing the query.
  3. Final Answer:

    The index on price must be updated for every row, slowing the update. -> Option A
  4. Quick Check:

    Index update overhead = slow UPDATE [OK]
Quick Trick: Mass updates on indexed columns slow queries due to index updates [OK]
Common Mistakes:
  • Blaming syntax errors without checking
  • Assuming indexes speed up UPDATEs
  • Thinking indexes are ignored on UPDATE

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes