From 16779f6069fbd7d4016e9b148174c48b72f1ac70 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Wed, 9 Jul 2014 12:32:00 +0400 Subject: [PATCH] MDEV-6430: It is impossible to see if "filesort with small limit" optimization was used - Make log_slow_verbosity print "Priority_queue: (Yes|No)" into the slow query log. (but we do not add a correspoding column to P_S.*statement* tables). --- sql/filesort.cc | 1 + sql/log.cc | 8 ++++++-- sql/log_slow.h | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/sql/filesort.cc b/sql/filesort.cc index 5ca6be2a2f4..e08d1812c23 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -225,6 +225,7 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length, table, num_rows, memory_available)) { DBUG_PRINT("info", ("filesort PQ is applicable")); + thd->query_plan_flags|= QPLAN_FILESORT_PRIORITY_QUEUE; const size_t compare_length= param.sort_length; if (pq.init(param.max_rows, true, // max_at_top diff --git a/sql/log.cc b/sql/log.cc index 4f9a1f2b746..82be25ed606 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -2904,7 +2904,8 @@ bool MYSQL_QUERY_LOG::write(THD *thd, time_t current_time, my_b_printf(&log_file, "# Full_scan: %s Full_join: %s " "Tmp_table: %s Tmp_table_on_disk: %s\n" - "# Filesort: %s Filesort_on_disk: %s Merge_passes: %lu\n", + "# Filesort: %s Filesort_on_disk: %s Merge_passes: %lu " + "Priority_queue: %s\n", ((thd->query_plan_flags & QPLAN_FULL_SCAN) ? "Yes" : "No"), ((thd->query_plan_flags & QPLAN_FULL_JOIN) ? "Yes" : "No"), ((thd->query_plan_flags & QPLAN_TMP_TABLE) ? "Yes" : "No"), @@ -2912,7 +2913,10 @@ bool MYSQL_QUERY_LOG::write(THD *thd, time_t current_time, ((thd->query_plan_flags & QPLAN_FILESORT) ? "Yes" : "No"), ((thd->query_plan_flags & QPLAN_FILESORT_DISK) ? "Yes" : "No"), - thd->query_plan_fsort_passes) == (size_t) -1) + thd->query_plan_fsort_passes, + ((thd->query_plan_flags & QPLAN_FILESORT_PRIORITY_QUEUE) ? + "Yes" : "No") + ) == (size_t) -1) tmp_errno= errno; if (thd->variables.log_slow_verbosity & LOG_SLOW_VERBOSITY_EXPLAIN && thd->lex->explain) diff --git a/sql/log_slow.h b/sql/log_slow.h index e8faf79a047..2ae07da97c3 100644 --- a/sql/log_slow.h +++ b/sql/log_slow.h @@ -31,6 +31,8 @@ #define QPLAN_QC_NO 1 << 6 #define QPLAN_TMP_DISK 1 << 7 #define QPLAN_TMP_TABLE 1 << 8 +#define QPLAN_FILESORT_PRIORITY_QUEUE 1 << 9 + /* ... */ #define QPLAN_MAX ((ulong) 1) << 31 /* reserved as placeholder */