update performance_schema.setup_instruments
set enabled='yes', timed='yes' where name like 'stage/%';
update performance_schema.setup_consumers
set enabled='yes' where name like '%stage%';
select sys.ps_thread_id(connection_id());
-- 当前
SELECT
stmt.SQL_TEXT AS sql_text, stage.EVENT_NAME,
CONCAT(WORK_COMPLETED, '/', WORK_ESTIMATED) AS progress,
(stage.TIMER_END - stmt.TIMER_START) / 1E12 AS current_seconds,
(stage.TIMER_END - stmt.TIMER_START) / 1E12 * (WORK_ESTIMATED - WORK_COMPLETED) / WORK_COMPLETED AS remaining_seconds
FROM
events_stages_current stage,
events_statements_current stmt
WHERE
stage.THREAD_ID = stmt.THREAD_ID
AND stage.NESTING_EVENT_ID = stmt.EVENT_ID;
-- 历史
SELECT
THREAD_ID,
EVENT_NAME,
SOURCE,
sys.format_time(TIMER_WAIT) AS exec_time,
WORK_COMPLETED,
WORK_ESTIMATED
FROM
performance_schema.events_stages_history_long
WHERE
thread_id = sys.ps_thread_id(CONNECTION_ID());
SELECT * FROM sys.session WHERE THREAD_ID = CONNECTION_ID() AND command = 'Query' AND trx_state='ACTIVE'\G;
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有