From b96dcfd42a598c6abb81c135ff768d392ac346cb Mon Sep 17 00:00:00 2001 From: ildyria Date: Fri, 23 Jun 2023 23:51:44 +0200 Subject: [PATCH] only explain when requested --- .env.example | 1 + app/Providers/AppServiceProvider.php | 2 +- config/database.php | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index fc9e51c21ec..dc65064bdb2 100644 --- a/.env.example +++ b/.env.example @@ -31,6 +31,7 @@ DB_PORT= DB_USERNAME= DB_PASSWORD= DB_LOG_SQL=false +DB_LOG_SQL_EXPLAIN=false #only for MySQL # List foreign keys in diagnostic page DB_LIST_FOREIGN_KEYS=true diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index ac68f769dec..fc46ab1948c 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -169,7 +169,7 @@ private function logSQL(QueryExecuted $query): void $msg = '(' . $query->time . 'ms) ' . $query->sql . ' [' . implode(', ', $query->bindings) . ']'; // For pgsql and sqlite we log the query and exit early - if (config('database.default', 'mysql') !== 'mysql') { + if (config('database.default', 'mysql') !== 'mysql' || config('database.explain', false) === false) { Log::debug($msg); return; diff --git a/config/database.php b/config/database.php index 4ab1ed272f1..9035cf09482 100644 --- a/config/database.php +++ b/config/database.php @@ -29,6 +29,7 @@ */ 'db_log_sql' => (bool) env('DB_LOG_SQL', false), + 'explain' => (bool) env('DB_LOG_SQL_EXPLAIN', false), /* |--------------------------------------------------------------------------