Skip to content

Commit

Permalink
Only apply explain when requested (#1896)
Browse files Browse the repository at this point in the history
  • Loading branch information
ildyria committed Jun 24, 2023
1 parent c8011b9 commit 2f949ba
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ private function logSQL(QueryExecuted $query): void
// Quick exit
if (
Str::contains(request()->getRequestUri(), 'logs', true)
|| Str::contains($query->sql, $this->ignore_log_SQL)
) {
return;
}
Expand All @@ -179,7 +180,6 @@ private function logSQL(QueryExecuted $query): void
if (config('database.default', 'mysql') !== 'mysql'
|| config('database.explain', false) === false
|| !Str::contains($query->sql, 'select')
|| Str::contains($query->sql, $this->ignore_log_SQL)
) {
Log::debug($msg);

Expand Down
1 change: 1 addition & 0 deletions config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
*/

'db_log_sql' => (bool) env('DB_LOG_SQL', false),
'explain' => (bool) env('DB_LOG_SQL_EXPLAIN', false),

/*
|--------------------------------------------------------------------------
Expand Down

0 comments on commit 2f949ba

Please sign in to comment.