2014/03/13

mysql table cache


★MySQL is MySQL はマルチスレッド化されているため、多数のクライアントが同時に同じものに対してクエリを使用することがあります。
2 つのクライアントスレッドで 1 つのファイルに異なるステータスが発生する問題を最小にするため、同時に実行しているスレッドがそれぞれで無関係にテーブルを開きます。
これはメモリの消費を増やしますが、一般にパフォーマンスは向上します。


table_open_cache
max_connections
max_tmp_tables-->サーバ変数は、サーバが開いた状態で保持できるファイルの最大数に影響します
OS によって制限されている 1 プロセスが持つことができるファイル記述子の最大数まで実行が可能になります。

MySQLは使用されていないテーブルが閉じられ、テーブルキャッシュから削除されます。
キャッシュが満杯のときに、キャッシュにないテーブルをスレッドが開こうとした場合。
キャッシュに table_open_cacheを超えるエントリがあり、あるスレッドがテーブルの使用を終えた場合。
テーブルフラッシュオペレーションが起きたとき。いずれかのユーザが FLUSH TABLES、mysqladmin flush-tablesまたは mysqladmin refreshを実行した場合。


★status:
Table_open_cache_hits
Table_open_cache_misses
Table_open_cache_overflows

Open_tables 512--->table_open_cacheに合う。
Opend_tables 47733ーー>開けたテーブル
   The number of tables that have been opened. If Opened_tables is big, your table_open_cache value is probably too small.
  
variables table_open_cache


 MySQL closes an unused table and removes it from the table cache under the following circumstances:

    When the cache is full and a thread tries to open a table that is not in the cache.
    When the cache contains more than table_open_cache entries and a table in the cache is no longer being used by any threads.
    When a table flushing operation occurs. T

 When the table cache fills up, the server uses the following procedure to locate a cache entry to use:

    Tables that are not currently in use are released, beginning with the table least recently used.
    If a new table needs to be opened, but the cache is full and no tables can be released, the cache is temporarily extended as necessary. When the cache is in a temporarily extended state and a table goes from a used to unused state, the table is closed and released from the cache.