<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆 - 41  文章 - 29  trackbacks - 0
    <2009年3月>
    22232425262728
    1234567
    891011121314
    15161718192021
    22232425262728
    2930311234

    常用鏈接

    留言簿(5)

    隨筆分類(28)

    隨筆檔案(23)

    收藏夾(6)

    Inside JVM

    Java

    java performance

    Solr

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    Database performance is the critical component of a web application. Recently, we spend lots of time to monitor and analyze SQL server performance based on SQL profiling log. However, SQL profiling log is row-based result set and is difficult to do trouble shooting directly. This message is trying to introduce some very good SQL monitoring and profiling tools to get much better SQL profiling result.

    Another Chinese Article on this topic

    There is a very good article about this topic. However, it is Chinese version. “http://www.ibm.com/developerworks/cn/java/j-lo-p6spy/index.html#resources”. 


    Background

    So, we are going to introduce three tools: P6Spy, IronTrackSQL and SQL Profiler (NOT SQL Server Profiler). Using these tools are very easy to log all SQL statements and show the detailed statistics results.

    P6Spy

    P6Spy is an open source framework for applications that intercept and optionally modify database statements. The P6Spy distribution includes the following modules:

    • P6Log. P6Log intercepts and logs the database statements of any application that uses JDBC. P6Spy is designed to be installed in minutes and requires no code changes.
    • P6Outage. P6Outage detects long-running statements that may be indicative of a database outage proble and will log any statement that surpasses the configurable time boundary during its execution.

    The deployment is very easy

    • Copy p6spy.jar to CLASSPATH. if web application, copy it to YourWebApp/WEB-INF/lib/
    • Copy spy.properties to CLASSPATH. if web application, copy it to YourWebApp/WEB-INF/classess/. NOTE: it is not lib.
    • Find your database connection setting, for example, Database resource setting within context.xml, and use “com.p6spy.engine.spy.P6SpyDriver” to replace the original driver class
    • Update the property “realdriver” as your real database driver as following:
      realdriver=net.sourceforge.jtds.jdbc.Driver
    • Run you application, and you find “spy.log” in your bin folder. And this log file path can be updated in spy.properties

    The Log Format

    current time|execution time|category|statement SQL String|effective SQL string


    1237024804522|93|5|statement|SELECT vp.purchaseID, vp.externalVendorID, vp.uniqueID, vp.purchaseWord, vp.purchaseValue, vp.purchaseType, vs.chains AS brands, vs.starRating, vs.amenities, vs.types, vsd.communityRatingTotal, vsd.communityRatingCount FROM VS_VendorPurchase AS vp LEFT JOIN VS_VendorSearch AS vs ON vp.externalVendorID = vs.externalVendorID LEFT JOIN VS_VendorSearchData AS vsd ON vp.externalVendorID = vsd.externalVendorID |SELECT vp.purchaseID, vp.externalVendorID, vp.uniqueID, vp.purchaseWord, vp.purchaseValue, vp.purchaseType, vs.chains AS brands, vs.starRating, vs.amenities, vs.types, vsd.communityRatingTotal, vsd.communityRatingCount FROM VS_VendorPurchase AS vp LEFT JOIN VS_VendorSearch AS vs ON vp.externalVendorID = vs.externalVendorID LEFT JOIN VS_VendorSearchData AS vsd ON vp.externalVendorID = vsd.externalVendorID

    Other Setting:
    P6Spy have lot of customized setting, such as time format, included table names or excluded table names, the interval values used to identify the long-running SQL, etc. Please see http://www.p6spy.com/documentation/other.htm.

    IronTrackSQL

    IronTrack SQL provides a GUI interface with reports and graphs and a detailed analysis of any SQL statement, comparing it with the system average.

    The deployment is also very easy

    • First of all, all jar files and property file need be copied from IronTrackSQL.zip
    • Copy irontracksql.jar, p6spy.jar and log4j-1.2.8.jar to CLASSPATH. if web application, copy it to YourWebApp/WEB-INF/lib/.
    • Copy spy.properties to CLASSPATH. if web application, copy it to YourWebApp/WEB-INF/classess/. NOTE: it is not lib.
    • Find your database connection setting, for example, Database resource setting within context.xml, and use “com.p6spy.engine.spy.P6SpyDriver” to replace the original driver class
    • Update the property “realdriver” as your real database driver as following:
      realdriver=net.sourceforge.jtds.jdbc.Driver
    • Run you application, and you find “spy.log” in your bin folder. And this log file path can be updated in spy.properties
    • Double click irontracksql.jar to start GUI, and click “File=>Connect” to connect to your application (or web server). From the status bar, you will see the connection information if successfully connecting to application

    GUI example

    • please see attached file
    • You can see count, average time and max time for each SQL statement
    • And you can filter logs based on some filter conditions, such as avg time from 10ms to 15ms

    Analyzing SQL Statement Performance with the SQL Monitor Section

    • High preparation time
      Queries that require high preparation time may perform unnecessary activities in the time between when a statement is initialized and when it is executed. Consider moving any code related to building the SQL query before creating the Statement object.
    • Frequent queries
      • Consider queries that are called frequently as candidates for data caching.
      • The Java PreparedStatement object gives the database an opportunity to pre-parse the query, which can save time when a query is called repeatedly.
      • Consider consolidating multiple queries of the same table into a single statement.
    • High execution time — Time spent in the executeQuery() or executeUpdate() methods is time that the database is spending to process and execute the query.
    • High retrieval time — Retrieval time includes all of the time spent returning records from the database to the application. The primary drivers of this time are the number of rows returned, and the amount of data in each row. Examine queries for opportunities to limit the number of columns, rows, or both returned.

    SQL Profiler – Not SQL Server Profiling


    This Swing-based SQL profiler tries to offer a tool to monitor which tables and columns are accessed the most in SQL queries to recommend index creation.

    The tool has the very similar capabilities of IronTrackSQL. However, i think IronTrackSQL has a better user interface. I recommend you to use IronTrackSQL.

    However, this tool can generate recommended indexes based on the SQL log. This is a very interesting feature.

    Overall

    Overall, these 3 tools facilitate developers on SQL statement logging and profiling without any code change, and is independent to any web container and database management system.

    Any issue, please let me know.

    posted on 2009-03-14 21:06 Justin Chen 閱讀(3547) 評論(0)  編輯  收藏 所屬分類: Tools
    主站蜘蛛池模板: 亚洲欧洲日产国码在线观看| 亚洲av午夜福利精品一区| 亚洲国产成人99精品激情在线| 香蕉免费一区二区三区| 亚洲人成在线电影| 久久精品免费视频观看| 亚洲av色影在线| **真实毛片免费观看| 亚洲精品人成电影网| 国产免费AV片在线播放唯爱网 | 亚洲日韩精品一区二区三区| 两个人看的www免费高清| 国产精品亚洲片在线观看不卡| 国产免费网站看v片在线| 亚洲av日韩av不卡在线观看| 免费国产黄网站在线观看视频| 亚洲精品美女在线观看播放| 永久免费av无码网站韩国毛片 | av午夜福利一片免费看久久| 亚洲中文久久精品无码| 免费人成在线观看网站品爱网 | 亚洲色偷偷狠狠综合网| 91免费在线视频| 亚洲精品国产福利片| 成年女人18级毛片毛片免费观看| 亚洲欧美日韩中文字幕一区二区三区| 一区二区三区亚洲视频| 美女无遮挡拍拍拍免费视频| 91精品国产亚洲爽啪在线影院| 野花高清在线观看免费完整版中文| 亚洲av午夜电影在线观看 | 中国在线观看免费的www| 亚洲av日韩av天堂影片精品| 成年女人18级毛片毛片免费 | 免费国产黄网站在线观看可以下载 | 精品无码无人网站免费视频| 亚洲熟妇AV一区二区三区浪潮| 亚洲精品第一国产综合境外资源| 久久久久国色av免费看| 亚洲最大天堂无码精品区| 久久亚洲精品无码播放|