From d4e1731fbc5f8fb05648a8b3e9ecd8bef4cafd36 Mon Sep 17 00:00:00 2001 From: Monty Date: Sun, 18 Feb 2024 16:05:42 +0200 Subject: [PATCH] Optimize handler_stats_disable() when handler_stats are already disabled MDEV-33502 Slowdown when running nested statement with many partitions --- sql/handler.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sql/handler.h b/sql/handler.h index 58e8bf64662..be0794a73a9 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -3456,6 +3456,7 @@ public: ("handler created F_UNLCK %d F_RDLCK %d F_WRLCK %d", F_UNLCK, F_RDLCK, F_WRLCK)); reset_statistics(); + active_handler_stats.active= 0; } virtual ~handler(void) { @@ -4877,9 +4878,12 @@ public: } inline void ha_handler_stats_disable() { - handler_stats= 0; - active_handler_stats.active= 0; - handler_stats_updated(); + if (handler_stats) + { + handler_stats= 0; + active_handler_stats.active= 0; + handler_stats_updated(); + } } private: