(Áú¹® Å볪¹«¸¦ °¨¼ÓÇϽʽÿÀ) MySQL µ¥ÀÌŸº£À̽º¿¡¼ ´À¸° Áú¹®ÀÇ ¹ú並 °¡´ÉÇÏ°Ô ÇϽʽÿÀ
ºü¸¥ °ÍÀ» À§ÇÑ ÁÖ¿ä ÇÊ¿äÁ¶°ÇÀÇ ÇÑ À¥ ¼¹ö ÀÖ´Ù ³«°üµÇ´Â Áú¹® ¶Ç´Â ´É·ü ÀûÀÌ°í ¹× È¿°úÀûÀÎ SQL °è»ê¼ ÀÌ ÀÌ´Ù. ³Ê¹« ±ä °¡Áö°í °¡°Å³ª ¼öÇàÇÏ´Â ±ä ½Ã°£ÀÌ ¸¹Àº ½Ã½ºÅÛ ÀÚ¿ø ³ôÀº ÂÊÀ¸·Î »ç¿ëÇÒ °è»ê¼ ¶Ç´Â ÀÏÀ¸Å°´Â ¿øÀÎÀÌ µÇ´Â ¾î¶² ºñ ÃÖ¼± SQL (±¸Á¶Àû Áú¹® ¾ð¾î) ¸í·É MySQL ´õ ´À¸° ´Þ¸®´Â µ¥ÀÌŸº£À̽º´Â, ±× ¶§ Á¡Á¡ À§·Î ¿À» Áþ´Â ÁÖ¹®Àܾ×À» Áú¹®Çϰí, ¿¬°á ÇѰ谡 µµ´ÞµÉ ¶§, ¹æ¹®ÀÚ´Â ºÎÁ¤µÇ°Å³ª ¿¬°áÀ» »çÀýÇß´Ù. ÃÖ¾ÇÀÇ °æ¿ìµµ °í·ÁÇÏ´Â ´ëº»¿¡¼´Â, ´ç½ÅÀÇ À¥ ¼¹ö´Â ¶ÇÇÑ ³»·Á°¥ °ÍÀÌ´Ù, ¶Ç´Â Áö¼ÓÀûÀ¸·Î underperform. ÄÉÀ̽º´Â ´ç½ÅÀÌ ³ôÀº ¼ÒÅë·® À¥»çÀÌÆ®¿¡¼ Àá±×´Â ÁÙ ¼öÁØ ´ë½Å¿¡ Àá±×´Â Å×ÀÌºí ¼öÁØÀ» ÀÌ¿ëÇÏ´Â MyISAM Å×À̺í À¯ÇüÀ» ÀÌ¿ëÇÒ ¶§ ƯÈ÷ Áø½ÇÇÏ´Ù.
¾ðÁ¨°¡, ´Ü Çϳª SQL Áú¹®Àº ¸ðµç ¼¹öÀÇ ¹®Á¦ÀÇ ¿øÀÎÀÏÁöµµ ¸ð¸¥´Ù. MySQL¿¡´Â ´À¸° Áú¹® Å볪¹«¸¦ ºÙÀâ°Å³ª ÃÖ¼± ±×¸®°í ³¡³»´Â ´ç½ÅÀÌ ÆÄÀÏ¿¡ MySQL µ¥ÀÌŸº£À̽º ¿£Áø¿¡ ÀÇÇÏ¿© ¼öÇàÇϱâ À§ÇÏ¿© ÃÊÀÇ Á¤ÀÇÇÑ ¼ö¸¦ ÀμöÇÑ ¸ðµç ÀÛÀº ´Þ¸®±â Áú¹®À» ¹úäÇÏ´Â °ÍÀ» Çã¿ëÇÏ´Â, Àå½Ã°£À» °É¸®±â À§ÇÏ¿© ÀÌÁö ¾Ê´Â Áú¹®À» È®ÀÎÇÏ´Â ºÙ¹ÚÀÌ ±â´ÉÀÌ ÀÖ´Ù. ´À¸° Áú¹® Å볪¹«´Â °úÅ MySQL ÀÓ¸í¿¡ ÀÇÇØ ¶Ç´Â À§¿¡ Ȱ¼ºÈµÇÁö ¾Ê´Â´Ù, µû¶ó¼ º¸´Ù Àû°Ô »ç¿ëÇÑ Å볪¹«ÀÇ ÇÑÀÌ´Ù.
´À¸° Áú¹® Å볪¹«¸¦ °¡´ÉÇÏ°Ô Çϱâ À§ÇÏ¿©´Â, °£´ÜÇÏ°Ô µÚ¿¡ ¿À´Â ¼±À» MySQL ±¸¼º ÆÄÀÏ¿¡ (my.cnf ¶Ç´Â my.ini) Ãß°¡Çϰí, ±× ÈÄ¿¡ MySQL ¼¹ö¸¦ ÀçÃâ¹ßÇϽʽÿÀ:
Å볪¹« ´À¸® Áú¹®ÇÑ´Ù
¶Ç´Â
= Å볪¹« ´À¸® Áú¹®ÇÑ´Ù [±â·Ï ÆÄÀÏ¿¡ °æ·Î]
´ëüÇϽʽÿÀ [±â·Ï ÆÄÀÏ¿¡ °æ·Î] ´À¸° Áú¹® ±â·Ï ÆÄÀÏ¿¡ ½ÇÁ¦ÀûÀÎ °æ·Î·Î ´ç½ÅÀº MySQL¸¦ ¼±Åà °¡Ä¡ÀÎ Å볪¹«¸¦¿¡ ¾²´Â ¿øÇÑ´Ù.
¶Ç´Â ´ç½ÅÀºÀ» °¡ÁøÀ» °¡Áø mysqld¸¦ ½ÃÀÛÇÒ ¼ö ÀÖ´Ù - [=file_name] ¼±ÅñÇÀ» ´À¸° Áú¹® Å볪¹«¸¦ °¡´ÉÇÏ°Ô Çϱâ À§ÇÏ¿© Å볪¹« ´À¸® Áú¹®ÇÑ´Ù. µÎ Åë¾î·Ð ÀüºÎ¿¡, ±×·¸Áö ¾ÊÀ¸¸é ±â·Ï ÆÄÀÏ À̸§Àº ÁöÁ¤µÈ´Ù, µðÆúÆ® À̸§Àº ÀÖ´Ù host_nameMySQL ÀÚ·á ÆÄÀÏ ÀüȹøÈ£ºÎ¿¡¼ ÀúÀåµÇ´Â -slow.log. ÆÄÀÏ À̸§ÀÌ Àý´ë ±æÀ̸§À¸·Î ¾Æ´Õ´Ï´Ù, ±×·¯³ª ÁÖ¾îÁö´Â °æ¿ì¿¡, ¼¹ö´Â ÀÚ·á µð·ºÅ丮¿¡ ÆÄÀÏÀ» ¿ª½Ã ¾´´Ù.
´À¸° Áú¹® Å볪¹«¸¦ °¡´ÉÇÏ°Ô Çϱâ ÈÄ¿¡, MySQL´Â ¼öÇàÇϱâ À§ÇÏ¿© 10 ÃÊ¿¡ ¼³Á¤µÈ ºÎÀü½ÂÀ¸·Î ÀÎ, long_query_time ÃÊ º¸´Ù´Â ´õ ¸¹Àº °ÍÀ» °¡Áö°í °£ ¸ðµç SQL °è»ê¼¸¦ °¡Áø ±â·Ï ÆÄÀÏ¿¡ âÁ¶Çϰí, ºÙÀâ°í ¹úäÇÒ °ÍÀÌ´Ù. óÀ½ Å×À̺í ÀÚ¹°¼è¸¦ ÃëµæÇÏ´Â ½Ã°£Àº ½ÇÇà ½Ã°£À¸·Î »ý°¢µÇÁö ¾Ê´Â´Ù. mysqld´Â ´À¸° Áú¹® Å볪¹«¿¡ ¼öÇàµÈ ÈÄ¿¡, ±×¸®°í ¸ðµç ÀÚ¹°¼è°¡ Ç®¾î ³õÀÎ ÈÄ¿¡ °è»ê¼¸¦ ¾´´Ù, ±×·¡¼ Å볪¹« ¼ø¼´Â ÁýÇà¸í·É°ú ´Ù¸¦ °ÍÀÌ Áöµµ ¸ð¸£´Ù.
You can then examine all the SQL queries that took longer than the pre-defined number of seconds (10 seconds by default) in the host_name-slow.log, and then take the necessary steps to optimize the SQL statements. The slow query log will tell you about what was time the query completed, how long the query took to run, how long it took to secure its locks, how many rows were sent back as a result, how many rows were examined to determine the result, which database was used, and the actual query itself. But bear in mind that a SQL query contained in the log may have already optimum, but executed slowly due to the system resources been used up by the actual slow statement that need to be fine tuned.
IMPORTANT: This is a machine translated page which is provided "as is" without warranty. Machine translation may be difficult to understand. Please refer to original English article whenever possible.
Share and contribute or get technical support and help at My Digital Life Forums.
Related Articles
- Change or Set MySQL Long Query Time Value for log-slow-queries
- Install Web Server in Windows XP with Apache2, PHP5 and MySQL4 - Part 4
- Change and Reset MySQL root Password
- WordPress MySQL SQL Query Error in WPDB Class
- You Are Not Authorized to Execute SQL Queries in vBulletin Maintenance
- How to Backup and Restore (Export and Import) MySQL Databases Tutorial
- MySQL Database Performance Tuning Best Practices Video Tutorial
- Fix for Munin MySQL Monitoring Plugin Graph Not Showing or Blank
- Using PHP-MySQL Persistent Connections to Run WordPress Blog
- How to Move WordPress Blog to New Domain or Location

































January 23rd, 2007 00:22
[...] If you enable slow queries log of MySQL database server, you will notice that from the slow query log file contains only SQL statements and queries that took more than query_time of 10 seconds to execute or run. This is the default value or query time threshold for log_slow_queries function, which is 10 seconds. 10 seconds is way too long for a SQL query to complete, so the value may be too high to capture any meaningful data. You can alter or change the slow query time to lower value or number of seconds. You can set a new long_query_time in the MySQL configuration file, namely my.cnf or my.ini, normally located in /etc directory. Simply add the following line to the configuration file: [...]