如何查看當前Innodb的併發線程數?
在MySQL中:
-
用
Threads_connected
表示當前數據庫server層的鏈接數,對應參數max_connections
; -
使用
Threads_running
表示已經連接的線程中,正在執行SQL的線程併發數 -
我們還知道在Innodb中還存在一個併發數的限制,可以參照參數
innodb_thread_concurrency
,它限制了進入Innodb執行某些操作的併發線程數。但是並沒有對應的狀態值statusshow global status
來表示當前有多少個線程進入了Innodb。
這個信息其實隱藏在了show engine innodb status
的結果中,見如下
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
0 read views open inside InnoDB
Process ID=3829, Main thread ID=140003619354368, state: sleeping
Number of rows inserted 1146913, updated 524289, deleted 1, read 6832252
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
其中0 queries inside InnoDB
就是當前進入innodb的併發
0 queries in queue
表示等待隊列FIFO中的線程中。
關於Innodb完整的併發控制策略,見
https://dev.mysql.com/doc/refman/5.7/en/innodb-performance-thread_concurrency.html