In the production environment, when the database runs abnormally slowly, DBA students will want to rush into the database to see how SQL runs. Why is the execution of statements so slow? In my production environment, multi-Table Association queries are often performed.
In the production environment, when the database runs abnormally slowly, DBA students will want to rush into the database to see how SQL runs. Why is the execution of statements so slow? In my production environment, multi-Table Association queries are often performed.
In the production environment, when the database runs abnormally slowly, DBA students will want to rush into the database to see how SQL runs. Why is the execution of statements so slow? In my production environment, multi-table join query statements often run slowly, most of which are I/O waits, therefore, the first step is to check whether there is a problem with the SQL Execution Plan. The second step is to use the SQL trace tool to track the actual running status of the SQL statement!
I. Use SQL _trace
1: the trace file that generates the select statement. Generally, tracefile_identifier is used to name the trace file. The Hong Kong server is used to facilitate searching.
2: Use the tkprof tool to filter the generated trace files and extract useful information. The default trace file outputs too much information!
Sys = no indicates that all sys user operations in the trace file are not output, including recursive SQL statements caused by user SQL statements, so that the output is concise;
Aggragate = yes indicates that the same SQL statement is merged in the input file, and the website space makes the output concise;
[Oracle @ dg53 udump] $ tkprof dg53_ora_10498_hr_trace01.trc/home/oracle/trace01.log aggregate = yes sys = no explain = hr/hr
[Oracle @ dg53 udump] $ wc-l dg53_ora_10498_hr_trace01.trc
1097 dg53_ora_10498_hr_trace01.trc
[Oracle @ dg53 udump] $ wc-l/home/oracle/trace01.log
137/home/oracle/trace01.log
[Oracle @ dg53 ~] $ Cat trace01.log
TKPROF: Release 10.2.0.1.0-Production on Fri Jun 8 12:06:23 2012
Copyright (c) 1982,200 5, Oracle. All rights reserved.
Trace file: dg53_ora_10498_hr_trace01.trc
Sort options: default
**************************************** ****************************************
Count = number of times OCI procedure was executed
Cpu = cpu time in seconds executing
Elapsed = elapsed time in seconds executing
Disk = number of physical reads of buffers from disk
Query = number of buffers gotten for consistent read
Current = number of buffers gotten in current mode (usually for update)
Rows = number of rows processed by the fetch or execute call
**************************************** ****************************************
Alter session set SQL _trace = true
Call count cpu elapsed disk query current rows
-----------------------------------------------------------------------
Parse 0 0.00 0.00 0 0 0 0
Execute 1 0.00 0.01 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
-----------------------------------------------------------------------
Total 1 0.00 0.01 0 0 0 0
Misses in library cache during parse: 0
Misses in library cache during execute: 1
Optimizer mode: ALL_ROWS
Parsing user id: 55 (HR)
**************************************** ****************************************
Select salary, last_name
From
Employees where employee_id = 100
Call count cpu elapsed disk query current rows
-----------------------------------------------------------------------
Parse 1 0.00 0.02 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.00 0.01 2 2 0 1
-----------------------------------------------------------------------
Total 4 0.00 0.04 2 2 0 1