MySQL SQL ProfilerÐÔÄÜ·ÖÎöÆ÷
ÉêÇëÁËMySQL°æÖ÷£¬ËµÒª15ÌìµÄ¿¼²ìÆÚ ¿´À´ÒªºÃºÃ±íÏÖÁË¡£²»ÄÜÔÙDZˮÁË¡£
¿´µ½ºÜ¶àÅóÓÑÎÊMySQLµÄÐÔÄÜ·ÖÎöÆ÷ ÒòΪMySQLÔÚÕâ·½Ãæ×öµÃ±È½Ï²î£¬Ò²¿ÉÄÜÎÒ²»ÖªµÀ ûÓÐMicrosoftµÄSQL Profiler,ҲûÓÐOracleµÄAuditºÍAWR ËùÒÔÎÒÃǺÜÄѵõ½Ò»Ð©SQLÓï¾äµÄͳ¼Æ£¬ÕâÒ²¸øÎÒÃǵ÷ÓÅ´øÀ´ÁËÀ§ÄÑ ¸üÄѵÄÊǶÔMySQLµÄ×·×Ù ÒÔǰд¹ý¸ö£¬²»¹ýÔÚ¿´¹ýmysqlÍøÕ¾ÉϵÄÒ»¸öbash½Å±¾ºó£¬¾õµÃ×Ô¼ºµÄÄǸö¾ÍÊÇСÎ×¼û´óÎ×ÁË ÏÖÄÃÀ´·ÖÏí¸ø´ó¼Ò£¬ºÜ¼òµ¥ # È¡µÃÍø¿¨eth0ÉϵÄËùÓвÙ×÷ time tcpdump -i eth0 -s 1500 -w 20060427-db-traffic-01.dmp # Õâ¸ö¿ÉÒÔÖ¸¶¨Ìض¨IPÇëÇóµÄ²Ù×÷£¬¿ÉÓÃÓÚ×·×Ù time tcpdump -i eth0 -s 1500 src host 192.168.2.10 -w 20060427-db-traffic-01.dmp # Õâ¸öÊǸñʽ»¯Êä³öÄãÒª½á¹û strings 20060427-db-traffic-01.dmp | grep -i 'select' | awk '{printf("%s %s %s %s\n", $1,$2,$3, $4);}'| sort| uniq -c | awk '{printf("%06ld %s %s %s %s\n", $1,$2,$3,$4,$5);}'|sort
µÃµ½µÄ½á¹û: cpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 1500 bytes 12000 packets captured 12000 packets received by filter 0 packets dropped by kernel real 0m8.666s user 0m0.006s sys 0m0.016s -------- 000001 select last_insert_id() from system_parameter ... 000122 select count(1) from visit_tracking 000122 select visitor_id 000800 select web_page_id , web_page_type_id 000800 select web_page_type_id , name 003200 select count(1) from hit_count 006400 select pd.parameter_value, 006400 select rp.user_id , rp.update_time
¿ÉÒÔ¿´µ½Ö´Ðи÷ÖÖselectµÄ´ÎÊý£¬µ±È»¸ÄһϾͿÉÒÔ¿´insert,updateÕâÖÖ²Ù×÷´ÎÊý ÅäºÏlog-slow-queries£¬Äã¿ÉÒÔ½øÒ»²½µÄÓÅ»¯ |