Bird
0
0

Given a table employees with columns id, name, and department, what will be the effect of creating an index on the department column?Consider the query: SELECT ...

medium📝 query result Q4 of 15
SQL - Indexes and Query Performance

Given a table employees with columns id, name, and department, what will be the effect of creating an index on the department column?

Consider the query: SELECT * FROM employees WHERE department = 'Sales';

AThe query will run faster by quickly locating 'Sales' rows
BThe query will run slower due to index overhead
CThe query will return no results
DThe index will delete rows not in 'Sales' department
Step-by-Step Solution
Solution:
  1. Step 1: Understand index effect on filtering queries

    An index on the department column helps the database find matching rows faster.
  2. Step 2: Analyze the query filtering by department='Sales'

    The index allows quick lookup of rows where department equals 'Sales', speeding up the query.
  3. Final Answer:

    The query will run faster by quickly locating 'Sales' rows -> Option A
  4. Quick Check:

    Index on filter column = faster query [OK]
Quick Trick: Index speeds up WHERE filtering on that column [OK]
Common Mistakes:
  • Thinking index slows down SELECT queries
  • Assuming index deletes or filters data automatically
  • Believing index changes query results

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes