sararzbn/queryspy

Laravel profiler for slow queries with smart suggestions

Installs: 6

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/sararzbn/queryspy

v1.1.2 2025-06-21 18:21 UTC

This package is auto-updated.

Last update: 2025-09-21 18:45:30 UTC


README

QuerySpy is a developer-friendly profiler for Laravel that captures slow SQL queries and suggests optimizations.

🚀 Features

  • Logs all slow database queries
  • Clean dashboard with filters and search
  • Smart suggestions (e.g. avoid SELECT *, use WHERE, add LIMIT)
  • CLI commands to export or clear query logs
  • Works out of the box with zero config
  • 100% test coverage

📦 Installation

To install the package, simply run the following Composer command:

composer require sararzbn/queryspy

⚙️ Configuration (optional)

php artisan vendor:publish --tag=queryspy-config

(Only needed if config publishing is supported)

🗄️ Database Migration

QuerySpy stores slow queries in a dedicated database table. To create it, run:

php artisan migrate

🖥️ Usage

Dashboard

Open in browser:

http://localhost:8000/queryspy

Trigger a slow query manually (for testing)

\DB::table('users')->whereRaw('pg_sleep(1)')->get();

pg_sleep(1) causes a delay on PostgreSQL.

🛠️ CLI Commands

Export queries:

php artisan queryspy:export --format=csv
php artisan queryspy:export --format=json

Clear the log file:

php artisan queryspy:clear

🧩 Roadmap

  • Live dashboard updates (AJAX polling)
  • Tag queries with request/user context
  • JOIN performance analyzer

👩‍💻 Author

Created with ❤️ by Sara Rouzbahani

📄 License

MIT License