DB2 SQL Performance Review and optimization

Source: Internet
Author: User
Tags db2 switches

1. Top10sql "with the most execution times"
DB2 "SELECT * from Sysibmadm.snapdyn_sql ORDER BY num_executions DESC FETCH first ten rows only"
2, the average execution time the longest Top10sql "
DB2 "SELECT * from Sysibmadm.top_dynamic_sql ORDER BY average_execution_time_s DESC FETCH first ten rows only"
3, the most ranked Top10sql "
DB2 "SELECT * from Sysibmadm.snapdyn_sql ORDER BY stmt_sorts DESC FETCH first ten rows only"

Executed using the instance user.

Find SQL with long run time

DB2 Get monitor Switches//get configuration of monitors

DB2 Update monitor switches using SORT on STATEMENT in TIMESTAMP on//Modify monitor settings

DB2 Reset monitor all//restart monitors

DB2 get snapshot for dynamic SQL on Dbname>sql//Get Snapshot

grep "Total execution Time" Sql|sort-rn +4>time//Get Runtime

Head-n 5 time//Get the top five running longer

Then put the time-consuming SQL into the Test.sql

Perform:

db2advis-d dbname-i test.sql-q Dbuser

To get optimization recommendations.

DB2 SQL Performance Review and optimization

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.