Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.1 » SQL Anywhere Server - SQL Usage » Monitoring and Improving Database Performance » Application profiling tutorials » Tutorial: Diagnosing slow statements


Lesson 2: Reviewing statements processed by the database server

You can identify which statements the database server spends the most time processing by using the Summary and Detail tabs, located in Application Profiling pane in Sybase Central.

To review statements processed by the database server
  1. Open the analysis file.

    1. In Sybase Central, choose Mode » Application Profiling. If the Application Profiling Wizard appears, click Cancel.

    2. Choose Application Profiling » Open Analysis File Connect To A Tracing Database.

    3. Select In A Tracing Database, and then click Open.

    4. Click the Identification tab, and type DBA in the User ID field, and sql in the Password field.

    5. Click the Database tab, and in the Database File field, browse to and select app_profiling - DBA.

    6. Click OK.

      If the Application Profiling Details pane does not appear at the bottom of the window, choose View » Application Profiling Details.

  2. Examine statement execution times of statements that were processed during the tracing session.

    1. On the Status tab in the Application Profiling Details pane, select the most recent ID (highest number) from the Logging Session ID field, and then click the Database Tracing Data tab.

    2. Data for the session appears.

      On the Summary tab, the SQL statements you executed during the session appear. You may see more additional statements as well. This is because statements you executed automatically caused other statements to be executed (for example, a trigger).

      The Summary tab groups similar statements together and summarizes the total number of invocations and the total time spent processing them. SELECT, INSERT, UPDATE, and DELETE statements are grouped together by what tables, columns, and expressions they reference. Other statements are grouped together as a whole (for example, all CREATE TABLE statements appear as a single entry in the Summary tab). A statement may appear expensive in the Summary tab because it is an expensive statement, or because it is frequently executed.

      Use the Total Time and Maximum Time columns to examine the execution times for the two queries you executed earlier in this tutorial. The first query shows a total time of 20 milliseconds for execution. The second query shows a faster execution time (16 milliseconds), indicating that the second query, which uses a uncorrelated subquery, may be a more efficient syntax to use.

      For each SQL statement executed during the tracing session, the number of invocations, total time, maximum time, user and statement text are shown.
  3. To view additional information about any SQL statement in the Summary tab, right-click the statement and choose Show The Detailed SQL Statements For The Selected Summary SQL Statement.

    • To view information about the connection that executed the statement, right-click the statement and choose View Connection Details For The Selected Statement.

    • To view the execution plan used for the statement, right-click the statement in the Details tab, and choose View More SQL Statement Details For The Selected Statement.

      The SQL Statement Details window appears, displaying the full text of the statement along with details about the context in which it was used. Note that the text displayed for the statement may not match the original SQL statement you executed. Instead, the SQL Statement Details window displays the statement in its rewritten form, as it was processed by the database server. For example, queries over views may appear very different, since the view definitions are often rewritten by the optimizer when executing the query.

      To view the execution plan, click the Query Information tab.

For more information on the items shown in the execution plan, see Reading execution plans.

For information about correlated and uncorrelated subqueries, see Using subqueries.

For information about using the Summary and Details tabs, see Perform request trace analysis.