Skip to main content
Back to packages
410 GitHub stars

halilcosdu/laravel-slower

View on GitHub

Description

Optimize Your DB Queries with AI

You can register the commands with your scheduler.

php artisan slower:clean /*{days=15} Delete records older than 15 days.*/
php artisan slower:analyze /*Analyze the records where is_analyzed=false*/
use HalilCosdu\Slower\Commands\AnalyzeQuery;
use HalilCosdu\Slower\Commands\SlowLogCleaner;
 
protected $commands = [
AnalyzeQuery::class,
SlowLogCleaner::class,
];
 
/**
* Define the application's command schedule.
*/
protected function schedule(Schedule $schedule): void
{
$schedule->command(AnalyzeQuery::class)->runInBackground()->daily();
$schedule->command(SlowLogCleaner::class)->runInBackground()->daily();
}
$model = \HalilCosdu\Slower\Models\SlowLog::first();
 
\HalilCosdu\Slower\Facades\Slower::analyze($model): Model;
 
dd($model->raw_sql); /*select count(*) as aggregate from "product_prices" where "product_id" = '1' and "price" = '0' and "discount_total" > '0'*/
 
dd($model->recommendation);

Example Screen

Screenshot

Related Content on Laravel Daily

Recent Courses on Laravel Daily

Practical Laravel Security: Packages, Secrets, Supply-Chain Attacks

7 lessons
43 min read

Testing in Laravel 13 For Beginners

26 lessons
1 h 41 min read

Laravel 13 Eloquent: Expert Level

41 lessons
1 h 34 min