Consider a table employees with 1 million rows and an index on the department_id column. Which query will likely run faster due to the index?
SELECT * FROM employees WHERE department_id = 5;
Think about how indexes help find specific values quickly without scanning the whole table.
Indexes speed up queries that filter on the indexed column by allowing the database to quickly locate matching rows instead of scanning all rows.
Given a table orders with multiple indexes, what happens to the speed of an INSERT operation?
INSERT INTO orders (order_id, customer_id, order_date) VALUES (101, 2001, '2024-01-01');
Consider what happens behind the scenes when data is added to a table with indexes.
Each index must be updated to include the new row, which adds overhead and slows down INSERT operations.
Which scenario is the best candidate for adding an index?
Think about when indexes provide the most benefit versus when they add unnecessary overhead.
Indexes are most useful on columns frequently used to filter large datasets. Columns rarely queried or frequently updated may not benefit from indexes.
Which SQL statement correctly creates an index on the email column of the users table?
Remember the standard SQL syntax for creating indexes.
The correct syntax is CREATE INDEX index_name ON table_name(column_name);
A table has 10 indexes on various columns. What is a likely consequence when running an UPDATE statement that modifies multiple columns?
Consider how indexes affect data modification operations like UPDATE.
Each index that covers updated columns must be maintained, which adds overhead and slows down UPDATE operations.