MySQL查询未记录到性能架构表

问题描述 投票:0回答:2

我正在运行一个简单的bash脚本,它从文件中读取select语句并执行查询,以便我可以收集查询的性能统计信息。

while read -r line || [[ -n $line ]]; do
    echo ${line//\\n/ }
    mysql ${MYSQL_CONN} -ANe"${line//\\n/ }" > select-output.txt 2>&1
done < ./test-stmts.txt

当我运行脚本时,查询成功执行,但没有记录到performance_schema.events_statement_current表或performance_schema.events_statement_history表。当我从MySQL Workbench执行相同的查询时,将在events_statement_current和events_statement_history表中捕获查询。

performance_schema已启用,并且还启用了相应的使用者:

events_statements_current   YES
events_statements_history   YES
events_statements_history_long  NO
statements_digest   YES

运行SHOW VARIABLES LIKE'performance_schema';从我的脚本返回performance_schema ON。

我是否需要在脚本中添加内容以便查询将记录到performance_schema?

谢谢

mysql
2个回答
© www.soinside.com 2019 - 2024. All rights reserved.