Menu

Find the indexes your Laravel app is missing, without touching the database
📰

Find the indexes your Laravel app is missing, without touching the database

DEV Community: laravel·Amjad Iqbal·8 days ago
#WUBnAHzd
#devtolaravel#devto#dev#mysql#laravel
Long article (312 words) — no AI summary yet.
Reading 0:00
15s threshold

Laravel MySQL Advisor is a read-only health advisor for the MySQL or MariaDB behind a Laravel app. It reports unused, duplicate and missing indexes, full table scans, N+1 patterns and server pressure, and shows the SQL or migration that fixes each one [1].

The problem

MySQL keeps most of this information in performance_schema and information_schema [1], but nothing in a Laravel app reads it for you. db:show lists sizes and db:monitor counts connections; neither says which index to drop. Two blind spots stand out:

foreignId('user_id') without ->constrained() creates no index.

An N+1 never shows in a slow-query log: it is one fast query run thousands of times.

How it works

composer require amjadiqbal/laravel-mysql-advisor php artisan mysql-advisor:report

Enter fullscreen mode

Exit fullscreen mode

Each finding has a severity (critical, warning or notice), the numbers behind it and, where it applies, the fix as SQL and as a Laravel migration.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.