3838
3939class AppServiceProvider extends ServiceProvider
4040{
41+ /**
42+ * Defines which queries to ignore when doing explain.
43+ *
44+ * @var array<int,string>
45+ */
46+ private array $ ignore_log_SQL =
47+ [
48+ 'information_schema ' , // Not interesting
49+
50+ // We do not want infinite loops
51+ 'EXPLAIN ' ,
52+
53+ // Way too noisy
54+ 'configs ' ,
55+ ];
56+
4157 public array $ singletons =
4258 [
4359 SymLinkFunctions::class => SymLinkFunctions::class,
@@ -151,8 +167,7 @@ private function logSQL(QueryExecuted $query): void
151167 {
152168 // Quick exit
153169 if (
154- Str::contains (request ()->getRequestUri (), 'logs ' , true ) ||
155- Str::contains ($ query ->sql , ['information_schema ' , 'EXPLAIN ' , 'configs ' ])
170+ Str::contains (request ()->getRequestUri (), 'logs ' , true )
156171 ) {
157172 return ;
158173 }
@@ -161,7 +176,11 @@ private function logSQL(QueryExecuted $query): void
161176 $ msg = '( ' . $ query ->time . 'ms) ' . $ query ->sql . ' [ ' . implode (', ' , $ query ->bindings ) . '] ' ;
162177
163178 // For pgsql and sqlite we log the query and exit early
164- if (config ('database.default ' , 'mysql ' ) !== 'mysql ' || config ('database.explain ' , false ) === false ) {
179+ if (config ('database.default ' , 'mysql ' ) !== 'mysql ' ||
180+ config ('database.explain ' , false ) === false ||
181+ !Str::contains ($ query ->sql , 'select ' ) ||
182+ Str::contains ($ query ->sql , $ this ->ignore_log_SQL )
183+ ) {
165184 Log::debug ($ msg );
166185
167186 return ;
0 commit comments