Performance Analysis of slow update statements

Source: Internet
Author: User
When I recently handled a problem, I first received an alarm about DBtime increase. Then I checked the DBtime and found that there was nearly 1000% of the load.

When dealing with a problem recently, I first received an alarm about increasing DB time, And then I checked the DB time and found that there was nearly 1000% of the load.

When dealing with a problem recently, I first received an alarm about increasing DB time, And then I checked the DB time and found that there was nearly 1000% of the load.

With curiosity, I want to see what kind of statement causes such a situation.

First, an awr report was captured. Because the problem occurred in a concentrated period of time and lasted for several hours, a snapshot was taken for an hour.

The awr part is as follows:

Cache Sizes

BeginEnd

Buffer Cache: 39,472 M39, 472 MStd Block Size: 8 K

Shared Pool Size: 1, memory M1, 440 MLog Buffer: 14,256 K

The following section shows that there are not many internal activities in the database, the redo volume is not high, and the tps is not high.
Load Profile

Per SecondPer Transaction

Redo size: 154,276.4124 and 024.13

Logical reads: 4, 864.90757.57

Block changes: 779.75121.42

Physical reads: 509.52.16.35

Physical writes: 359.9056.04

User cballs: 2, 658.46413.98

Parses: 837.89130.48

Hard parses: 0.090.01

Sorts: 171.2226.66

Logons: 0.470.07

Executes: 949.10147.80

Transactions: 6.42

Looking at the wait time, we found that the first wait event was db file sequential read, with an average wait time of nearly 17 ms,

Generally, the latency is less than 10 ms, or at least 100 reads/sec. When the SAN-based Cache data is stored, the sequential read metric is sometimes kept at around 2 ms, this only indicates that SAN has converted data into cache, but it does not indicate that the hard drive is indeed fast. It has exceeded 10 ms, indicating that there is still a large impact on IO. Let's take a look at this problem first.

EventWaitsTime (s) Avg Wait (MS) % Total Call TimeWait Class

Db file sequential read917, 81015,310 1796.1 User I/O

CPU time 596 3.7

Log Files sync16, 085186121.2 Commit

Log file parallel write15, 4661409.9 System I/O

ARCH wait on sendreq3721327.1network


According to the time model, most of the DB time is in the SQL statement, so it is very important to pay attention to SQL statements.

Statistic NameTime (s) % of DB Time

SQL execute elapsed time15, 533.4397.47

DB CPU596.113.74

Connection management call elapsed time82.890.52

Parse time elapsed2017220.13

The SQL statement top1 surprised me and was actually a very simple update.

Elapsed Time (s) CPU Time (s) ExecutionsElap per Exec (s) % Total DB TimeSQL IdSQL ModuleSQL Text

8, 6596962213.9254.34 update user_test t set t. login_status = ''where t. CN_TEST =: 1

The first thought was that this statement had gone through full table scanning, because it took nearly 13 seconds for a simple Update, and it was a long time.
Of course, we also need to verify the guess. Let's take a look at the awrsqrpt results.
I found this report quite interesting. The execution plan adopts the unique index scan, so there is no problem in the execution plan.

IdOperationNameRowsBytesCost (% CPU) Time

0 update statement 1 (100)

1 UPDATEUSER_BILLING

2 index unique SCANIDX_USER_TEST_CNMASTER1301 (0) 00:00:01

However, it is strange to view the execution statistics of SQL statements.

Stat NameStatement TotalPer Execution % Snap Total

Elapsed Time (MS) 8,659,180 13, 921.5154.34

CPU Time (MS) 69,346 111.4911.63

Executions622

Buffer Gets3, 146, 0685, 057.9935.91

Disk Reads645, 2291,037.3570 .31

Parse Calls6221.000.04

Rows621, 827999.72

User I/O Wait Time (MS) 8,608,075

The execution of SQL statements lasted about 622 S, and the 8608s time was spent on the user I/O wait. In this way, the execution of times actually took less time.
I am also confused about this problem and began to doubt whether it was a problem with disk I/O.
However, when you use MegaCli to view the block, it is found that no bad block exists.
# MegaCli-CfgDsply-a0 | grep Error
Media Error Count: 0
Other Error Count: 0
Media Error Count: 0
Other Error Count: 0
Media Error Count: 0
Other Error Count: 0
Media Error Count: 0
Other Error Count: 0
Media Error Count: 0
Other Error Count: 0
Media Error Count: 0
Other Error Count: 0
Media Error Count: 0
At this time, a guess is that the SQL Performance problem may be caused by the different data types of the bound variables. However, after some troubleshooting, we found that we still did not get the expected results.
Check that all input parameter types are expected varchar2. Therefore, the possibility of full table scan is not displayed during SQL statements.
Select name, datatype_string, value_string, datatype from DBA_HIST_SQLBIND where SQL _id = '94p345yuqh3zd' and snap_id between 58711 and 58712
NAME DATATYPE_STRING VALUE_STRING DATATYPE
-------------------------------------------------------------------------------------
: 1 VARCHAR2 (128) xxxxxx9@test.com 1
: 1 VARCHAR2 (128) 23234324324234 1
For the I/O bottleneck problem, you still get what you need from addm.
The addm report describes the disk throughput.

FINDING 6: 39% impact (6136 seconds)
------------------------------------
The throughput of the I/O subsystem was significantly lower than expected.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.