MySQL中profiling的使用 简介

---测试环境 在MySQL Workbench的SQL Query窗口执行通过
-- 1
SELECT @@profiling;

-- 2
SET profiling = 1;

-- 3
 create table test.tmp_bak475_1 select * from  test.tmp_bak475;
 
-- 4
select count(*) from test.tmp_bak475_1;

-- 5
SHOW PROFILES;

-- 6
show profile cpu, block io for query 4;
show profile  for query 4;
SELECT sum( FORMAT(DURATION, 6)) AS DURATION FROM INFORMATION_SCHEMA.PROFILING WHERE QUERY_ID =5 ORDER BY SEQ;
SELECT sum( FORMAT(DURATION, 6)) AS DURATION FROM INFORMATION_SCHEMA.PROFILING WHERE QUERY_ID =9 ORDER BY SEQ;

 

这里比较出2次执行第4条sql的时间效率。

你可能感兴趣的:(MYSQL)