| Bug #107903 | Contribution: Each slow log prints out the database name | ||
|---|---|---|---|
| Submitted: | 18 Jul 2022 14:42 | Modified: | 24 Jul 2025 7:00 |
| Reporter: | OCA Admin (OCA) | Email Updates: | |
| Status: | Verified | Impact on me: | |
| Category: | MySQL Server: Logging | Severity: | S3 (Non-critical) |
| Version: | 8.0 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | Contribution | ||
[18 Jul 2022 14:42]
OCA Admin
[18 Jul 2022 14:42]
OCA Admin
Contribution submitted via Github - Each slow log prints out the database name (*) Contribution by yadong bai (Github diyuhuodong, mysql-server/pull/416#issuecomment-1186981887): I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.
Contribution: git_patch_998858982.txt (text/plain), 806 bytes.
[24 Jul 2025 7:00]
MySQL Verification Team
Hello yadong bai, Thank you for the report and contribution. regards, Umesh
[24 Mar 12:28]
Pandravada Sumedha
Thank you for your contribution, but unfortunately we can’t consider the patch. Currently, the slow query log only emits a 'use <db>;' when the active database changes. This helps keep the log concise and avoids redundancy. With your patch, we would log use <db>; before every statement, even if no change occurred. This would significantly increase the size of the log and could lead to bloated log files, making them less readable and harder to analyze. Regarding log rotation: when the slow log is rotated manually using FLUSH SLOW LOGS, the command reopens the slow-log file via reopen_log_file(). This logs the 'use <db>;' statement alongside the flush operation, for example: # Query_time: 0.002122 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0 use repro_db; SET timestamp=1774246409; FLUSH SLOW LOGS; # Time: 2026-03-23T06:13:48.354641Z This ensures that database context is preserved after the rotation, so it is not necessary to print the database name for every entry. Thank you again for your initiative and contribution. If you have any further questions or suggestions, please let us know.
