Sunday, February 4, 2018

Mysql Speed Too Many Opening tables

Thanks
https://pantheon.io/blog/profiling-mysql-queries-better-performance


SET profiling = 1;
SHOW PROFILES; 
SHOW PROFILE FOR QUERY 1;

SELECT STATE, SUM(DURATION) AS Total_R,
   ROUND(
   100 * SUM(DURATION) / (SELECT SUM(DURATION) FROM INFORMATION_SCHEMA.PROFILING WHERE QUERY_ID = @query_id), 2
   ) AS Pct_R,
   COUNT(*) AS Calls,
   SUM(DURATION) / COUNT(*) AS "R/Call"
   FROM INFORMATION_SCHEMA.PROFILING
   WHERE QUERY_ID = @query_id
   GROUP BY STATE
   ORDER BY Total_R DESC;


show status where `variable_name` = 'Threads_connected';
innodb_buffer_pool_size=Try to Maximum 
 
Disable query caching 

//SET GLOBAL query_cache_size = 1000000;
 
Thanks 
 
https://web.archive.org/web/20160129162137/http://www.psce.com/blog/kb/how-query-cache-can-cause-performance-problems/
https://dev.mysql.com/doc/refman/5.7/en/query-cache-configuration.html
 
Try to add  
 Localhost or internal ip 
 
https://dba.stackexchange.com/questions/54756/large-database-too-much-time-spent-opening-and-closing-tables 
https://www.percona.com/blog/2009/11/18/how-innodb_open_files-affects-performance/ 
 
https://stackoverflow.com/questions/9930556/innodb-table-optimization-w-o-locking-table