Skip to content

Composite Indexes in MySQL: The Fix for Slow Laravel Filter Pages

M Mohamed Khalifa
A property search page went from 3.2s to 0.9s with two composite indexes. Here is how to find which indexes your filters actually need.

Filter pages combine multiple WHERE clauses — city, price range, status — and single-column indexes rarely help. MySQL picks one index and scans the rest.

Find the real query

Enable the slow query log or use DB::listen() locally, then run EXPLAIN on the worst offender. If you see type: ALL or huge rows estimates, you need a composite index matching your filter order:

$table->index(['city_id', 'status', 'price']);

Order matters: equality columns first, ranges last. After adding the right two indexes on a client project, the search page dropped from 3.2s to 0.9s with zero code changes.

Back to Blog Performance

Keep reading

Related Articles

Next deploy

Got a project in mind? Let's build it right.

Open a production channel. Architecture first. Delivery owned end to end.

visitor@khalifadev:~ ● ready

$ Contact::connect();

✓ channel open

info@khalifadev.com

$ Mail::send( 'next-system' );