0
0
MySQLquery~20 mins

Index maintenance in MySQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Index Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
Effect of Dropping an Index on Query Performance

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?

MySQL
DROP INDEX idx_last_name ON employees;
AThe query will run slower because it will perform a full table scan.
BThe query will run faster because the index is removed.
CThe query will return no results because the index is missing.
DThe query will cause a syntax error due to missing index.
Attempts:
2 left
💡 Hint

Think about how indexes help MySQL find rows quickly.

🧠 Conceptual
intermediate
1:30remaining
Purpose of Index Maintenance in Databases

Why is regular index maintenance important in a MySQL database?

ATo automatically update data in the tables without queries.
BTo prevent users from accessing the database during peak hours.
CTo reduce disk space by deleting all indexes periodically.
DTo ensure indexes remain efficient by reorganizing or rebuilding them.
Attempts:
2 left
💡 Hint

Think about what happens to indexes as data changes over time.

📝 Syntax
advanced
2:00remaining
Correct Syntax to Rebuild an Index in MySQL

Which of the following commands correctly rebuilds an index named idx_customer_name on the customers table?

AALTER TABLE customers DROP INDEX idx_customer_name, ADD INDEX idx_customer_name (customer_name);
BREBUILD INDEX idx_customer_name ON customers;
COPTIMIZE TABLE customers REBUILD INDEX idx_customer_name;
DALTER INDEX idx_customer_name REBUILD ON customers;
Attempts:
2 left
💡 Hint

MySQL does not have a direct REBUILD INDEX command.

optimization
advanced
2:00remaining
Choosing the Best Index Type for Frequent Range Queries

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?

AA HASH index on <code>date_of_purchase</code>.
BA FULLTEXT index on <code>date_of_purchase</code>.
CA BTREE index on <code>date_of_purchase</code>.
DNo index is needed for range queries.
Attempts:
2 left
💡 Hint

Consider which index type supports range scans efficiently.

🔧 Debug
expert
2:30remaining
Diagnosing Slow Query Despite Index Presence

A query filtering on email column is slow even though there is an index on email. Which reason below best explains this?

AThe index is corrupted and needs to be rebuilt.
BThe query uses a function on <code>email</code> column, preventing index use.
CThe table is too small to benefit from indexes.
DThe index is a FULLTEXT index, which is not used for filtering.
Attempts:
2 left
💡 Hint

Think about how functions in WHERE clauses affect index usage.