SunQuest
           UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old March 20th, 2008, 12:12 AM
shantanuo shantanuo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Location: Mumbai, India
Posts: 242 shantanuo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 15 h 18 m 16 sec
Reputation Power: 9
Unhappy Data from log files

I have set long query time to 2 seconds in my cnf file.
Therefore all the queries taking more than 2 seconds are logged in the file called mysql-slow.log and the file size is 20 Mb.
Is there anyway to sort this file and find out the queries those are taking the most time so that I can optimize only those ones?
Here is how the file look like....

# Time: 080319 16:32:11
# User@Host: root[root] @ [192.29.0.134]
# Query_time: 5 Lock_time: 0 Rows_sent: 0 Rows_examined: 0
INSERT INTO queryLog SET id = '', filename = 'intermediate.php',queryLength = '72',exeTime = '0';
# Time: 080319 17:13:33
# User@Host: root[root] @ [192.29.3.143]
# Query_time: 9 Lock_time: 0 Rows_sent: 1 Rows_examined: 872116
select distinct(business_group) from d_jds.tbl_company_master limit 10;

Reply With Quote
  #2  
Old March 20th, 2008, 08:21 AM
pdreyer pdreyer is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2007
Posts: 38 pdreyer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 1 m 37 sec
Reputation Power: 1
grep -n Query_time mysql-slow.log | sort -k 3,3nr
7:# Query_time: 9 Lock_time: 0 Rows_sent: 1 Rows_examined: 872116
3:# Query_time: 5 Lock_time: 0 Rows_sent: 0 Rows_examined: 0

Then use the line numbers from grep to examine the longest running query
# sed -n '7,/;$/p' mysql-slow.log
# Query_time: 9 Lock_time: 0 Rows_sent: 1 Rows_examined: 872116
select distinct(business_group) from d_jds.tbl_company_master limit 10;

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Data from log files


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway