Indexes speed up data retrieval by allowing MySQL to find rows quickly without scanning the entire table.
They trade a bit of storage and write performance for much faster SELECT
queries.
-- Single-column index CREATE INDEX idx_lastname ON employees(last_name); -- Composite index CREATE INDEX idx_dept_salary ON employees(department_id, salary); -- Fulltext index (for text search) CREATE FULLTEXT INDEX ft_idx_content ON articles(content);
-- Drop by name DROP INDEX idx_lastname ON employees; -- For fulltext/spatial, same syntax DROP INDEX ft_idx_content ON articles;
WHERE
, JOIN
, ORDER BY
or GROUP BY
.INSERT
/UPDATE
/DELETE
.EXPLAIN
to see if MySQL uses your index for a query.ANALYZE TABLE
and OPTIMIZE TABLE
to update statistics.Help others discover Technorank Learning by sharing your honest experience.
Your support inspires us to keep building!