I’m troubleshooting slow queries on MySQL 8 and need advice.
I have a table salla_events (~1M rows). The queries look like this:
SELECT *
FROM salla_events
WHERE event = 'order.created'
AND merchant = 2021223349
AND created_at >= '2025-08-15 22:09:20';
According to the slow query log, each query takes between 7–11 seconds and scans ~1.1M rows.
I’ve already created indexes:
CREATE INDEX idx_event_merchant_created
ON salla_events (event, merchant, created_at);
But the slow logs still show Rows_examined: 1120350+.
Here is part of mysql slow log:
User@Host: lamour_bot[lamour_bot] @ localhost [127.0.0.1] Id: 424571 # Query_time: 9.989759 Lock_time: 0.000005 Rows_sent: 5 Rows_examined: 1120379 SET timestamp=1755371566; select * from salla_events where event = 'order.created' and merchant = 1056778926 and created_at >= '2025-08-15 22:12:46';
Why is MySQL ignoring or underusing this index?
I’m using MySQL 8.0 with InnoDB and the queries are run frequently from a Laravel app.
Any advice on why this indexed query is still slow would be appreciated.
SELECT COUNT(*) FROM salla_events WHERE event = 'order.created' AND merchant = 2021223349 AND created_at >= '2025-08-15 22:09:20'. What is the count of rows that match the query conditions?SELECT *has to go to the table rows to fetch the rest of the data, and that takes time with 1.3M rows. This is whySELECT COUNT(*)is fast, butSELECT *is slow.(merchant, event, created_at)helps. Test index forcing.