(Áú¹® Å볪¹«¸¦ °¨¼ÓÇϽʽÿÀ) 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.



One Response to ¡°Enable Logging of Slow Queries (Slow Query Log) in MySQL Database¡±

  1. Change or Set MySQL Long Query Time Value for log-slow-queries » My Digital Life
    January 23rd, 2007 00:22
    1

    [...] 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: [...]

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe without commenting


Custom Search

New Articles

Incoming Search Terms for the Article

enable slow query log - query to change the default database engine in mysql - mysql slow query log - default query log file name - enable log slow queries in mysql - enable slow query log my.ini - log-slow-queries - my.cnf enable logging - my.cnf mysql slow - my.cnf slow-log - my.cnf log queries - my.cnf slow queries - my.ini logging - mysql enable slow queries - mysql stop slow queries; - mysql query log my.ini windows - mysql query logging configuration - mysql slow query log +my.cnf - mysql slow query log my.cnf - mysql slow query log limit - mysql capture query - mysql query logging - mysql turn on slow query - mysql long query - mysql detect slow query - mysql slow query tool - mysql log slow queries - mysql slow log for windows - Slow Query Log ini - slow query my.cnf - slow query log mysql "my.cnf" - slow query log ini file - start mysql windows The Slow Query Log - turning on slow query logging in mysql - turn on mysql slow quey log - default mysql slow query - disable slow query log for single query - enable long query logging mysql - IS MYSQL SERVER TOO SLOW - log-slow-queries my.ini - my.ini slow query log - mysql my.cnf set execution limit - mysql enable slow query logging? - mysql log slow queries my.cnf - mysql slow query log enable - mysql logging config - mysql is not logging slow queries - mysql + slow query - mysql query log my.cnf - mysql my.ini logging -