Adding an index made my query slower. Here's why.
go
dev.to
Repo: github.com/bitorsic/export-service I built a Go service that exports large datasets to CSV in the background. Along the way, adding an index to a slow query made it slower, not faster. Here's what happened and what actually fixed it. The query The service exports a seller's order history, joined across four tables: SELECT o.order_id, o.order_status, o.order_purchase_timestamp, c.customer_id, c.customer_city, c.customer_state, p.product_category, oi.price