Skip to content

Instantly share code, notes, and snippets.

@InnaTarasyan
Created November 29, 2025 16:40
Show Gist options
  • Select an option

  • Save InnaTarasyan/3c6c38f49b8b582c03e75cbc77039619 to your computer and use it in GitHub Desktop.

Select an option

Save InnaTarasyan/3c6c38f49b8b582c03e75cbc77039619 to your computer and use it in GitHub Desktop.
Log Only Slow Queries (>100ms)
// app/Providers/AppServiceProvider.php
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
public function boot()
{
DB::listen(function ($query) {
if ($query->time > 100) {
Log::warning('Slow Query: '.$query->sql, [
'time_ms' => $query->time,
'bindings' => $query->bindings,
]);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment