1. 程式人生 > 其它 >mysql檢視佔用記憶體或者CPU高的SQL

mysql檢視佔用記憶體或者CPU高的SQL

技術標籤:Mysql

獲取mysql程序id

ps -ef | grep -i mysql

實時檢視mysql程序中佔用CPU,記憶體最多的作業系統執行緒ID

top -p 2341 -H

根據作業系統執行緒ID,檢視mysql資料庫中對應的執行緒ID

select thread_id,name ,PROCESSLIST_ID,THREAD_OS_ID from threads where thread_os_id = 2341 ;

根據mysql資料庫的執行緒ID獲取sql

select sql_text from performance_schema.events_statements_current where
thread_id = 34 \G;