如何观测MySQL DDL的进度

-- 查看相关的PS监控指标是否开启
SELECT *
  FROM PERFORMANCE_SCHEMA.SETUP_INSTRUMENTS
 WHERE NAME LIKE 'stage/innodb/alter%';

SELECT *
  FROM PERFORMANCE_SCHEMA.SETUP_CONSUMERS
 WHERE NAME LIKE '%stages%';

-- 可动态开启相关指标
UPDATE PERFORMANCE_SCHEMA.SETUP_INSTRUMENTS
   SET ENABLED = 'YES'
 WHERE NAME LIKE 'stage/innodb/alter%';

UPDATE PERFORMANCE_SCHEMA.SETUP_CONSUMERS
   SET ENABLED = 'YES'
 WHERE NAME LIKE '%stages%';

如何观测MySQL DDL的进度

如何观测MySQL DDL的进度

以下命令可观测当前DDL的执行进度,预估时间

SELECT STMT.SQL_TEXT,
       STAGE.EVENT_NAME,
       CONCAT(WORK_COMPLETED, '/', WORK_ESTIMATED) AS PROGRESS,
       CONCAT(ROUND(100 * WORK_COMPLETED / WORK_ESTIMATED, 2), ' %') AS PROCESSING_PCT,
       SYS.FORMAT_TIME(STAGE.TIMER_WAIT) AS TIME_COSTS,
       CONCAT(ROUND((STAGE.TIMER_END - STMT.TIMER_START) / 1E12 *
                    (WORK_ESTIMATED - WORK_COMPLETED) / WORK_COMPLETED,
                    2),
              ' s') AS REMAINING_SECONDS
  FROM PERFORMANCE_SCHEMA.EVENTS_STAGES_CURRENT     STAGE,
       PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_CURRENT STMT
 WHERE STAGE.THREAD_ID = STMT.THREAD_ID
   AND STAGE.NESTING_EVENT_ID = STMT.EVENT_ID\G

如何观测MySQL DDL的进度

上一篇:Prometheus + Alertmanager 实现企微告警


下一篇:vue-cli-service build --mode stage 打包之后没有css如何解决