结合操作系统线程 查看mysql中的sql资源 消耗

来源:这里教程网 时间:2026-03-01 15:56:09 作者:

结合操作系统线程 查看mysql中的sql资源 消耗  (5.7 才可以, 5.7时  performance_schema.threads表 才加入的 thread_os_id 系统线程字段)  --1、执行一个大sql mysql> update test_limit_table set b=round(rand()*b,0); --2、查看cpu高的线程是 2142,top -H 的时候 此时PID不是进程ID 而是线程id(LWP id) [root@hostmysql80 mysql]# top -H ......                                                     2142 mysql     20   0 2195448  74992   2348 R 83.1 26.4   0:03.78 mysqld                                                                                                                          --3、查看 2142线程的 具体的sql mysql> SELECT a.name,               a.thread_id,               a.thread_os_id,               a.processlist_id,               a.type,               b.user,               b.host,               b.db,               b.command,               b.time,               b.state,               b.info          FROM performance_schema.threads a          LEFT JOIN information_schema.processlist b            ON a.processlist_id = b.id         where a.type = 'FOREGROUND'           and a.thread_os_id =2142;       

相关推荐