summaryrefslogtreecommitdiff
path: root/sql/sql_test.cc
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2020-03-06 10:33:11 +0200
committerMonty <monty@mariadb.org>2020-03-09 13:49:06 +0200
commit940fcbe73bc0aad18bb77a45428126ff987b96c4 (patch)
treef432fa53c226da7c6934e5b6439358585f130fa4 /sql/sql_test.cc
parent1ad8693a6f6b44121651a0c7ccf80ae1f099744d (diff)
downloadmariadb-git-940fcbe73bc0aad18bb77a45428126ff987b96c4.tar.gz
Improved speed of optimizer trace
- Added unlikely() to optimize for not having optimizer trace enabled - Made THD::trace_started() inline - Added 'if (trace_enabled())' around some potentially expensive code (not many found) - Added ASSERT's to ensure we don't call expensive optimizer trace calls if optimizer trace is not enabled - Added length to Json_writer functions to speed up buffer writes when optimizer trace is enabled. - Changed LEX_CSTRING argument handling to not send full struct to writer function on_add_str() functions now trusts length arguments
Diffstat (limited to 'sql/sql_test.cc')
-rw-r--r--sql/sql_test.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/sql/sql_test.cc b/sql/sql_test.cc
index 68d30d5fecb..a3506687a72 100644
--- a/sql/sql_test.cc
+++ b/sql/sql_test.cc
@@ -658,9 +658,12 @@ Memory allocated by threads: %s\n",
void print_keyuse_array_for_trace(THD *thd, DYNAMIC_ARRAY *keyuse_array)
{
+ DBUG_ASSERT(thd->trace_started());
+
Json_writer_object wrapper(thd);
Json_writer_array trace_key_uses(thd, "ref_optimizer_key_uses");
- for(uint i=0; i < keyuse_array->elements; i++)
+
+ for (uint i=0; i < keyuse_array->elements; i++)
{
KEYUSE *keyuse= (KEYUSE*)dynamic_array_ptr(keyuse_array, i);
Json_writer_object keyuse_elem(thd);