Add an index for a frequently filtered column.

Section: indexes

Create a simple index

sql
sql
CREATE INDEX idx_orders_created_at ON orders (created_at);
Explanation

Useful for range scans, sorting, and recent-record lookups.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing indexes
Create a composite index
Index multiple columns in left-to-right order.
OpenIn sheetsqlsame section
Inspect indexes on a table
Display index metadata for a table.
OpenIn sheetsqlsame section
Drop an index
Remove an index that is unused or harmful.
OpenIn sheetsqlsame section
Explain a SELECT query
View the optimizer's execution plan.
Run EXPLAIN ANALYZE
Execute the query and include actual timing information.
Refresh table statistics
Update optimizer statistics for a table.