Q1. What is an index in MySQL and how does it improve query performance?
An index is a data structure (typically a B-tree) that MySQL maintains alongside a table to allow fast lookups without scanning every row. Without an index a SELECT with a WHERE clause requires a full table scan — O(n). With an index MySQL can find matching rows in O(log n). Primary keys are always indexed. Add indexes on columns used in WHERE, JOIN ON, and ORDER BY clauses for frequently run queries. The downside: indexes slow down INSERT/UPDATE/DELETE because MySQL must update the index. Use EXPLAIN to see whether queries use indexes.