Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: 系统变量tidb_stmt_summary_max_sql_lengt和配置参数stmt-summary.max-sql-length 到底谁生效
The system variable tidb_stmt_summary_max_sql_length
and the configuration parameter stmt-summary.max-sql-length
are both related to the length of the SQL displayed in information_schema.STATEMENTS_SUMMARY
according to the official documentation. However, what is their actual function?
Official documentation for the system variable tidb_stmt_summary_max_sql_length
:
Official documentation for the configuration parameter stmt-summary.max-sql-length
:
First, it can be seen that the system variable tidb_stmt_summary_max_sql_length
is not set based on the value of the configuration parameter stmt-summary.max-sql-length
:
Experiment 1:
The value of the system variable tidb_stmt_summary_max_sql_length
is 10.
The value of the configuration parameter stmt-summary.max-sql-length
is 20480.
Execute the following SQL statement:
select sbtest2.k, sbtest3.k, sbtest2.id, sbtest1.k, sbtest1.id, sbtest3.id from sbtest1 join sbtest2 on sbtest1.id=sbtest2.id join sbtest3 on sbtest2.id=sbtest3.id
It is found that the output of
DIGEST_TEXT
and QUERY_SAMPLE_TEXT
in the statement summary tables is truncated.
Experiment 2:
The value of the system variable tidb_stmt_summary_max_sql_length
is 20480.
The value of the configuration parameter stmt-summary.max-sql-length
is 10.
Execute the following SQL statement:
select sbtest2.k, sbtest3.k, sbtest2.id, sbtest1.k, sbtest1.id, sbtest3.id from sbtest1 join sbtest2 on sbtest1.id=sbtest2.id join sbtest3 on sbtest2.id=sbtest3.id;
It is found that the output of DIGEST_TEXT
and QUERY_SAMPLE_TEXT
in the statement summary tables is not truncated.
The scope of these two parameters or system variables is still a bit confusing.
Based on the above two experiments, I am not sure if the following guesses are correct:
-
According to the official documentation, the configuration parameter
stmt-summary.max-sql-length
controls the maximum display length of theDIGEST_TEXT
andQUERY_SAMPLE_TEXT
columns in the statement summary tables. However, from Experiment 1, even if the configuration parameterstmt-summary.max-sql-length
is set to 20480, it does not control the maximum display length of theDIGEST_TEXT
andQUERY_SAMPLE_TEXT
columns in the statement summary tables. -
From Experiment 2, when the configuration parameter
stmt-summary.max-sql-length
is lower than the system variabletidb_stmt_summary_max_sql_length
, the SQL strings in the statement summary tables can display the full length (includingDIGEST_TEXT
andQUERY_SAMPLE_TEXT
).
From these two experiments, there is a guess that the maximum display length of the DIGEST_TEXT
and QUERY_SAMPLE_TEXT
columns in the statement summary tables is actually controlled by the system variable tidb_stmt_summary_max_sql_length
.