国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > MySQL > 正文

mysql Key_buffer_size參數的優化設置

2024-07-24 12:46:32
字體:
來源:轉載
供稿:網友

先來看看document對這個參數的解釋:

緩存myisam表的索引塊大小,可以被所有進程所共享。當設置key_buffer_size,操作系統不會馬上分配key_buffer_size設置的值,而是在需要的時候,再分配的。可以設置多個key_buffer,當設置不是默認key_buffer為0時,mysql會把緩存的索引塊移到默認的key_buffer中去并刪除不再使用的索引塊。Myisam表中只能cache索引塊,不能cache數據塊。

原本描述:

Index blocks for MyISAM tables are buffered and are shared by all threads. key_buffer_size is the size of the buffer used for index blocks. The key buffer is also known as the key cache.

The maximum allowable setting for key_buffer_size is 4GB on 32-bit platforms. As of MySQL 5.0.52, values larger than 4GB are allowed for 64-bit platforms (except 64-bit Windows, for which large values are truncated to 4GB with a warning). The effective maximum size might be less, depending on your available physical RAM and per-process RAM limits imposed by your operating system or hardware platform. The value of this variable indicates the amount of memory requested. Internally, the server allocates as much memory as possible up to this amount, but the actual allocation might be less.

Increase the value to get better index handling (for all reads and multiple writes) to as much as you can afford. Using a value that is 25% of total memory on a machine that mainly runs MySQL is quite common. However, if you make the value too large (for example, more than 50% of your total memory) your system might start to page and become extremely slow. MySQL relies on the operating system to perform file system caching for data reads, so you must leave some room for the file system cache. Consider also the memory requirements of other storage engines.

1、建立緩存索引 :

mysql> set global key_buffer_1.key_buffer_size=8384512;
Query OK, 0 rows affected (0.01 sec)
mysql> set global key_buffer_2.key_buffer_size=8384512;
Query OK, 0 rows affected (0.01 sec)

2、把指定表放到key buffer中

mysql> cache index t1,t2 in key_buffer_1;
+————+——————–+———-+———-+
| Table | Op | Msg_type | Msg_text |
+————+——————–+———-+———-+
| luoxuan.t1 | assign_to_keycache | status | OK |
| luoxuan.t2 | assign_to_keycache | status | OK |
+————+——————–+———-+———-+
2 rows in set (0.00 sec)

3、預先裝載表的索引塊

mysql> load index into cache t1,t2;
+————+————–+———-+———-+
| Table | Op | Msg_type | Msg_text |
+————+————–+———-+———-+
| luoxuan.t1 | preload_keys | status | OK |
| luoxuan.t2 | preload_keys | status | OK |
+————+————–+———-+———-+
2 rows in set (0.00 sec)

下面我們來看一下,如果計算命中率及key buffer的使用率

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 涿鹿县| 广丰县| 凭祥市| 雅安市| 梅州市| 永定县| 锦屏县| 沈阳市| 布拖县| 双鸭山市| 怀化市| 延长县| 宝清县| 宿松县| 庐江县| 讷河市| 漯河市| 尤溪县| 苍南县| 阿荣旗| 牟定县| 嘉禾县| 冀州市| 五指山市| 远安县| 准格尔旗| 夏津县| 霍林郭勒市| 海宁市| 丹棱县| 微博| 且末县| 万载县| 吉隆县| 房产| 宝坻区| 灵山县| 华容县| 曲沃县| 南丹县| 图木舒克市|