Consider a MySQL table employees with a non-unique index on the last_name column. You run the following query:
SELECT * FROM employees WHERE last_name = 'Smith';
If you drop the index on last_name, what is the most likely effect on the query's execution?
DROP INDEX idx_last_name ON employees;
Think about how indexes help MySQL find rows quickly.
Indexes help MySQL locate rows without scanning the entire table. Dropping the index forces MySQL to scan all rows, making the query slower.
Why is regular index maintenance important in a MySQL database?
Think about what happens to indexes as data changes over time.
As data is inserted, updated, or deleted, indexes can become fragmented or less efficient. Maintenance like rebuilding or reorganizing keeps them fast.
Which of the following commands correctly rebuilds an index named idx_customer_name on the customers table?
MySQL does not have a direct REBUILD INDEX command.
MySQL rebuilds an index by dropping and recreating it using ALTER TABLE commands. Options A, C, and D are invalid syntax.
You have a large MySQL table with a date_of_purchase column. You often run queries filtering purchases between two dates. Which index type is best to optimize these range queries?
Consider which index type supports range scans efficiently.
BTREE indexes support range queries efficiently. HASH indexes are good for exact matches but not ranges. FULLTEXT is for text searching.
A query filtering on email column is slow even though there is an index on email. Which reason below best explains this?
Think about how functions in WHERE clauses affect index usage.
Using functions on indexed columns in WHERE clauses disables index usage because MySQL cannot use the index for transformed values.