Skip to Main Content
  • Questions
  • Sql Tuning Set and INSERT/MERGE statements

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Roberto.

Asked: February 24, 2016 - 9:32 am UTC

Last updated: February 25, 2016 - 3:39 pm UTC

Version: 11.2.0.2.0

Viewed 1000+ times

You Asked

Hi All,

I'm using Sql Tuning Set and DBMS_SQLPA to identify possible performance issues after applying some changes to the system. Our database uses many insert and merge statements but I can't see any in the captured set, I only see select and update ones. Is this a limitation of STS or I'm doing something wrong?
Thanks for any help!

--- Update (sorry I did not provide enough details!!!)
Let's say that I'm working on DB2 that is clone of DB1. I want to create a Sql Tuning Set on DB2 but capturing the statements that were executed on DB1 (I can't connect directly to DB1). The oracle packages that are provided to create the tuning set accept snapshot ids from current database, so in my case DB2.
Problem is that I need to use snapshot ids from DB1, basically I need to filter the dbid on DBA_HIST_SQL_PLAN.
DBMS_SQLTUNE.SELECT_WORKLOAD_REPOSITORY and DBMS_SQLTUNE.SELECT_CURSOR_CACHE use current dbid so it won't work.
Is there any way to do that using packages provided by Oracle?

and Chris said...

I believe you'll need to build the tuning set on DB1, then export it to DB2. The outline of this process is:

- In the production database, pack the STS into a staging table using DBMS_SQLTUNE.PACK_STGTAB_SQLSET.

- Export the STS from the staging table to a .dmp file using Oracle Data Pump.

- Transfer the .dmp file from the production host to the test host using a transfer tool such as ftp.

- In the test database, import the STS from the .dmp file to a staging table using Oracle Data Pump.

- Unpack the STS from the staging table using DBMS_SQLTUNE.UNPACK_STGTAB_SQLSET.


You can find more details in the docs:

http://docs.oracle.com/database/121/TGSQL/tgsql_sts.htm#TGSQL533

Is this answer out of date? If it is, please let us know via a Comment

More to Explore

Data Pump

All of the database utilities including Data Pump are explained in the Utilities guide.