MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sql_profile.cc File Reference
#include "sql_priv.h"
#include "unireg.h"
#include "sql_profile.h"
#include "my_sys.h"
#include "sql_show.h"
#include "sql_class.h"
#include <algorithm>
Include dependency graph for sql_profile.cc:

Go to the source code of this file.

Macros

#define TIME_FLOAT_DIGITS   9
#define TIME_I_S_DECIMAL_SIZE   (TIME_FLOAT_DIGITS*100)+(TIME_FLOAT_DIGITS-3)
#define MAX_QUERY_LENGTH   300U
#define MAX_QUERY_HISTORY   101U

Functions

int fill_query_profile_statistics_info (THD *thd, TABLE_LIST *tables, Item *cond)
int make_profile_table_for_show (THD *thd, ST_SCHEMA_TABLE *schema_table)

Variables

ST_FIELD_INFO query_profile_statistics_info []

Detailed Description

Implement query profiling as as list of metaphorical fences, with one fence per query, and each fencepost a change of thd->proc_info state (with a snapshot of system statistics). When asked, we can then iterate over the fenceposts and calculate the distance between them, to inform the user what happened during a particular query or thd->proc_info state.

User variables that inform profiling behavior:

  • "profiling", boolean, session only, "Are queries profiled?"
  • "profiling_history_size", integer, session + global, "Num queries stored?"

Definition in file sql_profile.cc.

Macro Definition Documentation

#define TIME_I_S_DECIMAL_SIZE   (TIME_FLOAT_DIGITS*100)+(TIME_FLOAT_DIGITS-3)

two vals encoded: (dec*100)+len

Definition at line 46 of file sql_profile.cc.

Function Documentation

int fill_query_profile_statistics_info ( THD *  thd,
TABLE_LIST tables,
Item cond 
)

Connects Information_Schema and Profiling.

Definition at line 54 of file sql_profile.cc.

Variable Documentation

ST_FIELD_INFO query_profile_statistics_info[]
Initial value:
{
{"QUERY_ID", 20, MYSQL_TYPE_LONG, 0, false, "Query_id", SKIP_OPEN_TABLE},
{"SEQ", 20, MYSQL_TYPE_LONG, 0, false, "Seq", SKIP_OPEN_TABLE},
{"STATE", 30, MYSQL_TYPE_STRING, 0, false, "Status", SKIP_OPEN_TABLE},
{"DURATION", TIME_I_S_DECIMAL_SIZE, MYSQL_TYPE_DECIMAL, 0, false, "Duration", SKIP_OPEN_TABLE},
{"CPU_USER", TIME_I_S_DECIMAL_SIZE, MYSQL_TYPE_DECIMAL, 0, true, "CPU_user", SKIP_OPEN_TABLE},
{"CPU_SYSTEM", TIME_I_S_DECIMAL_SIZE, MYSQL_TYPE_DECIMAL, 0, true, "CPU_system", SKIP_OPEN_TABLE},
{"CONTEXT_VOLUNTARY", 20, MYSQL_TYPE_LONG, 0, true, "Context_voluntary", SKIP_OPEN_TABLE},
{"CONTEXT_INVOLUNTARY", 20, MYSQL_TYPE_LONG, 0, true, "Context_involuntary", SKIP_OPEN_TABLE},
{"BLOCK_OPS_IN", 20, MYSQL_TYPE_LONG, 0, true, "Block_ops_in", SKIP_OPEN_TABLE},
{"BLOCK_OPS_OUT", 20, MYSQL_TYPE_LONG, 0, true, "Block_ops_out", SKIP_OPEN_TABLE},
{"MESSAGES_SENT", 20, MYSQL_TYPE_LONG, 0, true, "Messages_sent", SKIP_OPEN_TABLE},
{"MESSAGES_RECEIVED", 20, MYSQL_TYPE_LONG, 0, true, "Messages_received", SKIP_OPEN_TABLE},
{"PAGE_FAULTS_MAJOR", 20, MYSQL_TYPE_LONG, 0, true, "Page_faults_major", SKIP_OPEN_TABLE},
{"PAGE_FAULTS_MINOR", 20, MYSQL_TYPE_LONG, 0, true, "Page_faults_minor", SKIP_OPEN_TABLE},
{"SWAPS", 20, MYSQL_TYPE_LONG, 0, true, "Swaps", SKIP_OPEN_TABLE},
{"SOURCE_FUNCTION", 30, MYSQL_TYPE_STRING, 0, true, "Source_function", SKIP_OPEN_TABLE},
{"SOURCE_FILE", 20, MYSQL_TYPE_STRING, 0, true, "Source_file", SKIP_OPEN_TABLE},
{"SOURCE_LINE", 20, MYSQL_TYPE_LONG, 0, true, "Source_line", SKIP_OPEN_TABLE},
{NULL, 0, MYSQL_TYPE_STRING, 0, true, NULL, 0}
}

Definition at line 65 of file sql_profile.cc.