laravel-slower  by halilcosdu

Laravel package for database query optimization

created 1 year ago
368 stars

Top 77.8% on sourcepulse

GitHubView on GitHub
Project Summary

This package helps Laravel developers optimize slow database queries by leveraging AI to suggest indexing strategies and other performance improvements. It targets developers seeking to debug and monitor application performance, offering actionable insights for streamlined database interactions.

How It Works

The package logs slow queries exceeding a configurable threshold. It then utilizes OpenAI's GPT-4 (or a specified model) to analyze the query's EXPLAIN ANALYZE output and schema information. The AI provides recommendations, such as composite index creation or data type corrections, to enhance query efficiency.

Quick Start & Requirements

  • Install via Composer: composer require halilcosdu/laravel-slower
  • Publish config and migrations: php artisan vendor:publish --tag="slower-config" and php artisan vendor:publish --tag="slower-migrations" && php artisan migrate
  • Requires PHP, Composer, Laravel, and an OpenAI API key.
  • Scheduled commands slower:clean and slower:analyze can be registered in the application's scheduler.

Highlighted Details

  • AI-powered recommendations for indexing and query optimization.
  • Configurable query execution time threshold.
  • Option to disable AI recommendations and OpenAI API calls.
  • Logs raw SQL, bindings, execution time, and AI-generated recommendations.

Maintenance & Community

  • Developed by Halil Cosdu.
  • Roadmap includes documentation, v2 development, an auto-indexer (premium), and a FilamentPHP plugin.
  • Contributing and security guidelines are available.

Licensing & Compatibility

  • Licensed under the MIT License.
  • Compatible with Laravel applications.

Limitations & Caveats

  • AI recommendations require an OpenAI API key and incur costs.
  • The effectiveness of AI suggestions depends on the quality of the provided schema and EXPLAIN ANALYZE output.
  • Auto-indexing is planned as a premium feature.
Health Check
Last commit

1 month ago

Responsiveness

1 day

Pull Requests (30d)
0
Issues (30d)
0
Star History
9 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.