Jump to content

Sql tuning

Recommended Posts

Hi Please tell me how to tune the below query.

Attached the explain plan for reference.

Also please note the object names po, prline, rfq, rfqline are views.

These views are having two select statements by using union all. The first select statement refers another schema table of same database and another select refers table from another database by using database link.

The scenario is like this...

I'm archiving old data into another database and current database has only few records to improve the performance of application. There are some users which required to generate reports by using two database (Production and Archived database.)

So the view is created like this..

Create or replace view schema2.v1

select col1,col2

from schema1.table1

union all

select col1, col2

from schema.table1@dblink;

The above scenario is explained for IBM Maximo application and we are using IBM OPTIM for archiving. Also the maximo is generating the sql and sending to database like below queries.

SELECT Count(*)
FROM   dummy_table
              FROM   po
              WHERE  ponum IN (SELECT ponum
                               FROM   prline
                               WHERE  ponum IS NOT NULL
                                      AND prnum = 'D-8178')
                      OR ponum IN (SELECT ponum
                                   FROM   rfqline
                                   WHERE  rfqnum IN (SELECT rfqnum
                                                     FROM   prline
                                                     WHERE  prnum = 'D-8178')))
                  FROM   rfq
                  WHERE  rfqnum IN (SELECT rfqnum
                                    FROM   prline
                                    WHERE  prnum = 'D-8178'));

Please help me out how to overcome these kind of problems.


Share this post

Link to post
Share on other sites


Start by looking at the consistent gets and physical reads using SQL*Plus:


This is not a trivial query because of the views.  Can you run the query against the base tables?  Please read carefully:


i would start by trying hints to alter the execution plan:


For the full details, see my Oracle SQL tuning book:


Good luck!

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now