I was wondering if there’s a way to decrease the opened files in mysql.
Details :
-
mysql 5.0.92
-
engine used : MyISAM
-
SHOW GLOBAL STATUS LIKE ‘Opened_tables’ : 150K
-
SHOW VARIABLES LIKE ‘%open%’ :
open_files_limit 200000 table_open_cache 40000
Solutions tried :
-
restart server : it works the opened tables counter is 0 but this isn’t a good solution from my pov since you will need a restart every week because the counter will increase fast
-
FLUSH TABLES : like the mysql doc said it should force all tables in use to close but this doesn’t happen
So any thoughts on this matter?
Generally, many open tables are nothing to worry about. If you come close to OS limits, you can increase this limits in the kernel settings:
How do I change the number of open files limit in Linux?
MySQL opens tables for each session independently to have better concurrency.
In detail, this is explained here
http://dev.mysql.com/doc/refman/5.5/en/table-cache.html
EDIT
To verify your assumption you could decrease
max_connectionsandtable_open_cachetemporarily bySET GLOBAL table_open_cache := newValue.The value can be adjusted dynamically without a server restart.
Prior MySQL 5.1 this variable is called table_cache
What I was trying to tell, is, that decreasing this value will probably even have a negative impact on performance in terms of less possible concurrent reads (queue get’s longer), instead you should try to increase the OS limit and increase
max_open_files, but maybe I just don’t see the point here