Bird
0
0

Consider a table employees with an index on department_id. What is the effect of this UPDATE statement?

medium📝 query result Q5 of 15
SQL - Indexes and Query Performance
Consider a table employees with an index on department_id. What is the effect of this UPDATE statement?
UPDATE employees SET department_id = 5 WHERE employee_id = 10;
AThe update is faster because the index helps locate the row.
BThe update fails because indexed columns cannot be changed.
CThe update is slower because the index on <code>department_id</code> must be updated.
DThe update runs at normal speed ignoring the index.
Step-by-Step Solution
Solution:
  1. Step 1: Identify the column being updated and its index

    The column department_id is indexed and is being updated.
  2. Step 2: Understand index maintenance on UPDATE

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

    The update is slower because the index on department_id must be updated. -> Option C
  4. Quick Check:

    Index update overhead = slower UPDATE [OK]
Quick Trick: Updating indexed columns slows UPDATE due to index changes [OK]
Common Mistakes:
  • Assuming indexes speed up UPDATE
  • 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