程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> 關於MYSQL數據庫 >> MySQL 線程管理

MySQL 線程管理

編輯:關於MYSQL數據庫

1、參數設置

(root:zw_75.58:Thu Nov 25 11:41:12 2010)[test]> show variables like 'thread%';

+----------------------------+---------------------------+

| Variable_name              | Value                     |

+----------------------------+---------------------------+

| thread_cache_size          | 8                         |

| thread_handling            | one-thread-per-connection |

| thread_stack               | 196608                    |

+----------------------------+---------------------------+

thread_cache_size:設置線程緩沖池中緩存線程的個數,對比Threads_created和Connections值thread_cache_size是否合理。

By examining the difference between the Connections and Threads_created status variables, you can see how efficIEnt the thread cache is.

thread_stack:每一個線程分配的內存大小。

the thread stack is too small, this limits the complexity of the SQL statements which the server can handle, the recursion depth of stored procedures, and other memory-consuming actions. To set a stack size of N bytes for each thread, start the server with --thread_stack=N. 

thread_handling:線程分配方式,主要有兩種:一種是one-thread-per-connection每一個連接對應於一個線程;一種是no-threads服務器只使用一個連接。 

2、線程監控信息

(root:zw_75.58:Thu Nov 25 11:41:22 2010)[test]> show global status like 'thread%';                        

+------------------------+-------+

| Variable_name          | Value |

+------------------------+-------+

| Threads_cached         | 1     |

| Threads_connected      | 2     |

| Threads_created        | 3     |

| Threads_running        | 1     |

+------------------------+-------+

Threads_cached:當前線程緩沖池中緩存線程數。

Threads_connected:當前連接服務器的線程數。

Threads_created:為處理客戶端連接而創建線程數。The number of threads created to handle connections. If Threads_created is big, you may want to increase the thread_cache_size value. 

The cache miss rate can be calculated as Threads_created/Connections. 

Threads_running:狀態處於非sleep狀態的線程數。

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved