Description:
In general, right now, mysql slow logs are really hard to parse. There is no fixed format for slowlog entity, because there might or might not be 'use database_name' statement, which is very important when it comes to assigning particular query to right database. From what i've noticed, it might be only tiny change, and extremely small footprint on I/O operations, due to nature of slowlog. Sendng patch for version 5.5. If that will be accepted, i can send patches for 5.6 and 5.7 versions.
How to repeat:
See 'Suggested fix'.
Suggested fix:
From ac11fb9222f247db4da007abc78aae5d0c691ce1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marcin=20Matlaszek?= <mmatlaszek@gmail.com>
Date: Wed, 4 Feb 2015 23:45:22 +0100
Subject: [PATCH] Write use statement to every slowlog entry
---
sql/log.cc | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/sql/log.cc b/sql/log.cc
index d322abc..a2a15f2 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -2737,11 +2737,10 @@ bool MYSQL_QUERY_LOG::write(THD *thd, time_t current_time,
(ulong) thd->sent_row_count,
(ulong) thd->examined_row_count) == (uint) -1)
tmp_errno= errno;
- if (thd->db && strcmp(thd->db, db))
- { // Database changed
+ if (thd->db)
+ { // Write use statement to every log entry
if (my_b_printf(&log_file,"use %s;\n",thd->db) == (uint) -1)
tmp_errno= errno;
- strmov(db,thd->db);
}
if (thd->stmt_depends_on_first_successful_insert_id_in_prev_stmt)
{