-
-
Notifications
You must be signed in to change notification settings - Fork 350
Do not log queries which are faster than 100ms by default #3435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
🚀 New features to boost your workflow:
|
@@ -199,6 +199,11 @@ private function logSQL(QueryExecuted $query): void | |||
return; | |||
} | |||
|
|||
// if the query is not slow enough, we do not log it. | |||
if ($query->time < config('database.log_sql_min_time', 100)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add info 100 is ms
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed ffcb421
| executed very fast and are not relevant for debugging. | ||
| | ||
*/ | ||
'log_sql_min_time' => (int) env('DB_LOG_SQL_MIN_TIME', 100), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add info 100 is ms
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed ffcb421
So we can focus on the slow queries.
This pull request introduces a feature to filter SQL query logging based on execution time, enhancing the application's debugging capabilities while reducing unnecessary log noise. The changes include adding a configuration option for a minimum query execution time and updating the logging logic accordingly.
Enhancements to SQL query logging:
app/Providers/AppServiceProvider.php
: Updated thelogSQL
method to skip logging SQL queries that execute faster than the configured minimum time (log_sql_min_time
). This prevents logging insignificant queries.config/database.php
: Added a new configuration option,log_sql_min_time
, which allows setting a minimum execution time (in milliseconds) for SQL queries to be logged. This provides more control over the volume of logged queries.