Scan count 17 logical reads 176543 showing in execution plan

Hello,
I am getting scan count 17 and logical reads 145634 and some time the query takes 2 minutes and sometime 5 seconds.Thelogical reads showing against a big table(Product and Orders) that is having 10 milions records.After procedure executed it gives only 7008
records as out put.
SELECT Cust.Name
FROM  dbo.Customers Cust WITH (NOLOCK)
INNER JOIN Products Prod WITH (NOLOCK) ON Cust.ID = Prod.CustID
INNER JOIN dbo.Orders  Ords WITH (NOLOCK) on Cust.RepID = prod.ProdId
INNER JOIN dbo.[Address] Adds WITH (NOLOCK) on Prod.id = Adds.Id 
WHERE ords.pickeddate between @startdate and @enddate
Please do the needful.

>>>>How to reduce logical reads against big tables?
Have a useful index/s . But please show the execution plan of the query as David pointed.
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence

Similar Messages

  • Tkprof not showing the Execution Plan for Statement

    Hi all
    using oracle 9i release 2
    I have issued the following statements
    alter session set sql_trace
    alter session set events '10046 trace name context forever, level 12';
    --then executed a pl-sql procedure
    after reading the traceout outfile it shows the Execution plan for statements directly wirtten under begin and end block and doesnot displays the plan for the statements written like this
    procedure a is
    cursor b is
    select ename,dname from dept a,emp b
    where a.deptno=b.deptno;
    begin
    for x in a loop --plan not found but stats are written
    select ename into v_ename from emp where empno=300; --does show the plan+stats
    end;
    what I am missing to get the actual plan in trace output file
    thanks in advance

    You have to exit sql*plus after running the procedure, example tkprof is below:
    declare
    cursor c is
    select ename, dname
    from emp, dept
    where emp.deptno = dept.deptno;
    begin
    for v_x in c
    loop
    dbms_output.put_line(v_x.ename || ' ' ||v_x.dname);
    end loop;
    end;
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 1 0.00 0.06 0 0 0 1
    Fetch 0 0.00 0.00 0 0 0 0
    total 2 0.00 0.06 0 0 0 1
    Misses in library cache during parse: 0
    Optimizer goal: CHOOSE
    Parsing user id: 68
    Elapsed times include waiting on following events:
    Event waited on Times Max. Wait Total Waited
    ---------------------------------------- Waited ---------- ------------
    SQL*Net message to client 1 0.00 0.00
    SQL*Net message from client 1 0.00 0.00
    SELECT ENAME, DNAME
    FROM
    EMP, DEPT WHERE EMP.DEPTNO = DEPT.DEPTNO
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 1 0.00 0.00 0 0 0 0
    Fetch 15 0.01 0.00 0 44 0 14
    total 17 0.01 0.00 0 44 0 14
    Misses in library cache during parse: 0
    Optimizer goal: CHOOSE
    Parsing user id: 68 (recursive depth: 1)
    Rows Row Source Operation
    14 NESTED LOOPS
    14 TABLE ACCESS FULL EMP
    14 TABLE ACCESS BY INDEX ROWID DEPT
    14 INDEX UNIQUE SCAN DEPT_PK (object id 40350)
    Best Regards
    Krystian Zieja / mob

  • Scan count VS logical Reads

    I have two versions of a query.
    1.  Scan count 136, logical reads 2776907,CPU time = 230848 ms,  elapsed time = 55753 ms.
    2. Scan count 0, logical reads 89225788, CPU time = 437696 ms,  elapsed time = 46195 ms.
    The only difference I can see is 2 query it taking lesser of 10 minutes. Which is good here?  Both Execution plan has lots of hash joins.
    Srinivasan

    Hi Srinivasan,
    Scan counts should be as low as possible. As for Logical Reads, you want them to be as high as possible and more than physical
    reads is preferred (read from cache as opposed to drive).
    Scan count: Number
    of index or table scans performed.
    logical reads: Number of pages read from the data cache.
    For more info you can refer the msdn link => http://msdn.microsoft.com/en-us/library/ms184361.aspx
    Regards Harsh

  • Multiple Executions Plans for the same SQL statement

    Dear experts,
    awrsqrpt.sql is showing multiple executions plans for a single SQL statement. How is it possible that one SQL statement will have multiple Executions Plans within the same AWR report.
    Below is the awrsqrpt's output for your reference.
    WORKLOAD REPOSITORY SQL Report
    Snapshot Period Summary
    DB Name         DB Id    Instance     Inst Num Release     RAC Host
    TESTDB          2157605839 TESTDB1               1 10.2.0.3.0  YES testhost1
                  Snap Id      Snap Time      Sessions Curs/Sess
    Begin Snap:     32541 11-Oct-08 21:00:13       248     141.1
      End Snap:     32542 11-Oct-08 21:15:06       245     143.4
       Elapsed:               14.88 (mins)
       DB Time:               12.18 (mins)
    SQL Summary                            DB/Inst: TESTDB/TESTDB1  Snaps: 32541-32542
                    Elapsed
       SQL Id      Time (ms)
    51szt7b736bmg     25,131
    Module: SQL*Plus
    UPDATE TEST SET TEST_TRN_DAY_CL = (SELECT (NVL(ACCT_CR_BAL,0) + NVL(ACCT_DR_BAL,
    0)) FROM ACCT WHERE ACCT_TRN_DT = (:B1 ) AND TEST_ACC_NB = ACCT_ACC_NB(+)) WHERE
    TEST_BATCH_DT = (:B1 )
    SQL ID: 51szt7b736bmg                  DB/Inst: TESTDB/TESTDB1  Snaps: 32541-32542
    -> 1st Capture and Last Capture Snap IDs
       refer to Snapshot IDs witin the snapshot range
    -> UPDATE TEST SET TEST_TRN_DAY_CL = (SELECT (NVL(ACCT_CR_BAL,0) + NVL(AC...
        Plan Hash           Total Elapsed                 1st Capture   Last Capture
    #   Value                    Time(ms)    Executions       Snap ID        Snap ID
    1   2960830398                 25,131             1         32542          32542
    2   3834848140                      0             0         32542          32542
    Plan 1(PHV: 2960830398)
    Plan Statistics                        DB/Inst: TESTDB/TESTDB1  Snaps: 32541-32542
    -> % Total DB Time is the Elapsed Time of the SQL statement divided
       into the Total Database Time multiplied by 100
    Stat Name                                Statement   Per Execution % Snap
    Elapsed Time (ms)                            25,131       25,130.7     3.4
    CPU Time (ms)                                23,270       23,270.2     3.9
    Executions                                        1            N/A     N/A
    Buffer Gets                               2,626,166    2,626,166.0    14.6
    Disk Reads                                      305          305.0     0.3
    Parse Calls                                       1            1.0     0.0
    Rows                                        371,735      371,735.0     N/A
    User I/O Wait Time (ms)                         564            N/A     N/A
    Cluster Wait Time (ms)                            0            N/A     N/A
    Application Wait Time (ms)                        0            N/A     N/A
    Concurrency Wait Time (ms)                        0            N/A     N/A
    Invalidations                                     0            N/A     N/A
    Version Count                                     2            N/A     N/A
    Sharable Mem(KB)                                 26            N/A     N/A
    Execution Plan
    | Id  | Operation                    | Name            | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | UPDATE STATEMENT             |                 |       |       |  1110 (100)|          |
    |   1 |  UPDATE                      | TEST            |       |       |            |          |
    |   2 |   TABLE ACCESS FULL          | TEST            |   116K|  2740K|  1110   (2)| 00:00:14 |
    |   3 |   TABLE ACCESS BY INDEX ROWID| ACCT            |     1 |    26 |     5   (0)| 00:00:01 |
    |   4 |    INDEX RANGE SCAN          | ACCT_DT_ACC_IDX |     1 |       |     4   (0)| 00:00:01 |
    Plan 2(PHV: 3834848140)
    Plan Statistics                        DB/Inst: TESTDB/TESTDB1  Snaps: 32541-32542
    -> % Total DB Time is the Elapsed Time of the SQL statement divided
       into the Total Database Time multiplied by 100
    Stat Name                                Statement   Per Execution % Snap
    Elapsed Time (ms)                                 0            N/A     0.0
    CPU Time (ms)                                     0            N/A     0.0
    Executions                                        0            N/A     N/A
    Buffer Gets                                       0            N/A     0.0
    Disk Reads                                        0            N/A     0.0
    Parse Calls                                       0            N/A     0.0
    Rows                                              0            N/A     N/A
    User I/O Wait Time (ms)                           0            N/A     N/A
    Cluster Wait Time (ms)                            0            N/A     N/A
    Application Wait Time (ms)                        0            N/A     N/A
    Concurrency Wait Time (ms)                        0            N/A     N/A
    Invalidations                                     0            N/A     N/A
    Version Count                                     2            N/A     N/A
    Sharable Mem(KB)                                 26            N/A     N/A
    Execution Plan
    | Id  | Operation                    | Name         | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | UPDATE STATEMENT             |              |       |       |     2 (100)|          |
    |   1 |  UPDATE                      | TEST         |       |       |            |          |
    |   2 |   TABLE ACCESS BY INDEX ROWID| TEST         |     1 |    28 |     2   (0)| 00:00:01 |
    |   3 |    INDEX RANGE SCAN          | TEST_DT_IND  |     1 |       |     1   (0)| 00:00:01 |
    |   4 |   TABLE ACCESS BY INDEX ROWID| ACCT         |     1 |    26 |     4   (0)| 00:00:01 |
    |   5 |    INDEX RANGE SCAN          | INDX_ACCT_DT |     1 |       |     3   (0)| 00:00:01 |
    Full SQL Text
    SQL ID       SQL Text
    51szt7b736bm UPDATE TEST SET TEST_TRN_DAY_CL = (SELECT (NVL(ACCT_CR_BAL, 0) +
                  NVL(ACCT_DR_BAL, 0)) FROM ACCT WHERE ACCT_TRN_DT = (:B1 ) AND PB
                 RN_ACC_NB = ACCT_ACC_NB(+)) WHERE TEST_BATCH_DT = (:B1 )Your input is highly appreciated.
    Thanks for taking your time in answering my question.
    Regards

    Oracle Lover3 wrote:
    Dear experts,
    awrsqrpt.sql is showing multiple executions plans for a single SQL statement. How is it possible that one SQL statement will have multiple Executions Plans within the same AWR report.If you're using bind variables and you've histograms on your columns which can be created by default in 10g due to the "SIZE AUTO" default "method_opt" parameter of DBMS_STATS.GATHER__STATS it is quite normal that you get different execution plans for the same SQL statement. Depending on the values passed when the statement is hard parsed (this feature is called "bind variable peeking" and enabled by default since 9i) an execution plan is determined and re-used for all further executions of the same "shared" SQL statement.
    If now your statement ages out of the shared pool or is invalidated due to some DDL or statistics gathering activity it will be re-parsed and again the values passed in that particular moment will determine the execution plan. If you have skewed data distribution and a histogram in place that reflects that skewness you might get different execution plans depending on the actual values used.
    Since this "flip-flop" behaviour can sometimes be counter-productive if you're unlucky and the values used to hard parse the statement leading to a plan that is unsuitable for the majority of values used afterwards, 11g introduced the "adaptive" cursor sharing that attempts to detect such a situation and can automatically re-evaluate the execution plan of the statement.
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

  • Oracle 11g R2 consuming 100% CPU on execution plans

    Hi Friends
    I just installed oracle 11.2.0.1.0 on Windows 2008 Server R2.
    I got 4GB of RAM = 2536MB for SGA and 600M for PGA
    I'm running a processes that is consuming 100% of CPU ant its showed on execution plan of every statement this utilization.
    I have worked with disk_asynch_io parameter to FALSE and had no improvement on performance.
    Reading a doc relating to a bug I set up the dbwr_io_slaves to 4 but no changes.
    Now I'm stuck on asynch descriptor resize wait event for more than 4 hours.
    Any ideias os tips or experience about this issue?
    Tks a lot

    Well, Tks for your help guys,
    The problem was solved "almost" at all by disabling MEMORY_TARGET and SGA_TARGET and setting up all the memory parameters manually.
    This has eliminated the event "asynch description resize" and the overall performance of the DB has increased. I was able then, to complete my operation.
    I believe its a Windows bug or a poor design or configuration of mine. But at this time we are able to run the system well and fast enough.
    Tks a lot

  • STATISTICS IO: Scan Count vs Logical reads

    Hello
    I'm doing som performance research, I have a index with following priority: ClientId, Active, ProductId. Active is a bit field telling whether the Product is active or not, it can be inactive products than active, but always at least one active product.
    When I'm executing
    SELECT * FROM [table] WHERE ClientId = [id] AND ProductId IN (1,2,3,5,7,9,20)
    I'm getting following result: Scan count 1, logical reads 490
    When I'm leading SQL Server to the right paths by including the to possible values in Active by executing the following SQL:
    SELECT * FROM [table] WHERE ClientId = [id] AND ProductId IN (1,2,3,5,7,9,20) AND Active IN (0,1)
    I'm getting following results: Scan count 14, logical reads 123
    With this information, which version would you say is fastest and why?
    When I was running this query 1000 times with different ClientId I got a average time of 172 ms for the first query, and 155 ms for the second one. I have been told that scan count is very expensive... out of this example it seems that the cost of 1 scan count is like 20 logical reads?

    When I was running this query 1000 times with different ClientId I got a average time of 172 ms for the first query, and 155 ms for the second one. I have been told that scan count is very expensive... out of this example
    it seems that the cost of 1 scan count is like 20 logical reads?
    Typically the pages are forced out of buffer (DBCC DROPCLEANBUFFERS) when doing such a measurement:
    http://www.sqlusa.com/bestpractices2005/executioninms/
    BOL: "Use DBCC DROPCLEANBUFFERS to test queries with a cold buffer cache without shutting down and restarting the server."
    LINK: http://technet.microsoft.com/en-us/library/ms187762.aspx
    Kalman Toth Database & OLAP Architect
    SELECT Video Tutorials 4 Hours
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • How to reduce logical count and scan count for a select query

    hi,
    I have two tables one is master and other is history. i need to combine this two tables into one temporary table.
    I am using the below query to create temp table.
    Select * into temporders
    from
    (select * from orders
    union
    select * from ordershistory) b
    where updateon= (select max(updateon)from (select updateon,name,units,subunits from orders
    union
    select updateon,name,units,subunits from ordershistory) a
    where updateon <='11/08/2008 11:18 AM' and a.name=b.name and a.units=b.units and a.subunits=b.subunits group by name,units,subunits)
    order by report,subunitsorder
    the statistics for this query:
    SQL Server parse and compile time:
    CPU time = 47 ms, elapsed time = 62 ms.
    Table 'Worktable'. Scan count 556, logical reads 1569, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
    Table 'ORDERSHISTORY'. Scan count 116, logical reads 339, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
    Table 'ORDERS'. Scan count 116, logical reads 285, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
    SQL Server Execution Times:
    CPU time = 32 ms, elapsed time = 63 ms.
    (115 row(s) affected)
    you see logical reads and scan count for worktable(temporary) is quite high.
    So anyone can give a solution for reduce the scan count and logical reads.
    NOTE: name,units, subunits,updateon columns have primarykey

    SQL ServerAm i reading it properly? :(
    This is Oracle Forum And not the SQL Server.
    Regards.
    Satyaki De.

  • How do I search scanned documents that Adobe Reader reads but shows 0 results from the search?

    How do I search scanned documents that Adobe Reader reads but shows 0 results from the search?

    If the scanned document was not processed for OCR, then it is just an image and cannot be searched for text.

  • Understanding Statistics io and Logical reads - is logical reads information correct

    Hi,
    This question arises during a performance test - on SQL Server 2012 with SP2.
    In the following example, table has only column and that is of data type INT.
    When inserted 592 records of data type INT it is doing only 1 logical read but as soon another record is inserted SP is reporting 2 logical reads. Why?
    In the code, i have highlighted difference between 
    statistics io - logical reads and sys.dm_exec_procedure_stats.total_logical_reads
    to understand the difference between these 2 information.
    set nocount on
    GO
    create table dbo.test_storage_and_logical_reads
    employee_number int --primary key
    GO
    go
    CREATE procedure dbo.test_sp_logical_reads
    as
    begin
    select
    employee_number
    from dbo.test_storage_and_logical_reads
    order by employee_number desc
    end
    go
    insert into dbo.test_storage_and_logical_reads
    (employee_number)
    VALUES (1)
    GO 592
    EXEC sp_spaceused 'dbo.test_storage_and_logical_reads'
    --set statistics io on
    --GO
    exec dbo.test_sp_logical_reads
    GO
    ----Table 'test_storage_and_logical_reads'. Scan count 1, logical reads 1, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
    ---- But sys.dm_exec_procedure_stats.total_logical_reads is reporting 3 instead.
    truncate table dbo.test_storage_and_logical_reads
    GO
    insert into dbo.test_storage_and_logical_reads
    (employee_number)
    VALUES (1)
    GO 593
    EXEC sp_spaceused 'dbo.test_storage_and_logical_reads'
    exec dbo.test_sp_logical_reads
    GO
    ----Table 'test_storage_and_logical_reads'. Scan count 1, logical reads 2, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
    ---- But sys.dm_exec_procedure_stats.total_logical_reads is reporting 4 instead.
    --drop procedure dbo.test_sp_logical_reads
    --drop table dbo.test_storage_and_logical_reads
    GO
    NB: I do understand the logical and physical reads. Thanks.
    For quick review of new features, try virtual labs: http://msdn.microsoft.com/en-us/aa570323

    Hi.
    I still need to test the scenario but if you read definition of this DMV it says 'Returns aggregate performance statistics for cached stored procedures' so I guess, I am not sure 3 can be due to this aggregated output given by this DMV. Will test it
    on SS 2012 SP2 will get back to you.
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it.
    My TechNet Wiki Articles
    Hi Shanky / Sean Gallardy
    i think Sean Gallardy created the "test_sp_logical_reads" table in master DB, i have that same issue when i accidentiatly created the table "test_sp_logical_reads" in master, but when i create the same table in USER DB like "sample1"
    it only allocate 1 page for 592,
    hi Asam,
    Let me narrow down the your question, if my understanding is correct ...
    <<When you have the free space in a page of a Heap, why SQL Server is assigning New page for a New Record>>
    Answer is in PFS bytes
    The answer is that PFS bytes are not fully reset until the page is reallocated. On deallocation, the only bit in the PFS byte that's changed is the allocation status bit - this makes it very easy to rollback a deallocation
    --Before inserting the 593 record plese execute the below query
    --Note Replace "database1" with your DBName
    DBCC TRACEON (3604);
    DBCC IND ('database1', 'test_storage_and_logical_reads', 1);
    --Result
    PageFID PagePID IAMFID IAMPID ObjectID IndexID PartitionNumber PartitionID iam_chain_type PageType IndexLevel NextPageFID NextPagePID PrevPageFID PrevPagePID
    1 2770 NULL NULL 517576882 0 1 72057594039828480 In-row data 10 NULL 0 0 0 0
    1 2769 1 2770 517576882 0 1 72057594039828480 In-row data 1 0 0 0 0 0
    --your intrested in the second record(page)
    DBCC PAGE ('database1', 1, 2769,3) WITH TABLERESULTS;
    --you can find 38th row as
    --PFS (1:1) = 0x64 MIXED_EXT ALLOCATED 100_PCT_FULL
    --which means your page is full
    --you can try inserting 300 rows it will show you PFS (1:1) = 0x61 MIXED_EXT ALLOCATED 50_PCT_FULL
    please refer in the below link
    http://blogs.msdn.com/b/sqlserverstorageengine/archive/2006/07/08/under-the-covers-gam-sgam-and-pfs-pages.aspx
    http://aboutsqlserver.com/2013/12/17/sql-server-storage-engine-heap-tables/
    "This page has a PFS byte value of 0x04 - how can it be full when its not allocated?"
    The answer is that PFS bytes are not fully reset until the page is reallocated. On deallocation, the only bit in the PFS byte that's changed is the allocation status bit - this makes it very easy to rollback a deallocation.
    Here's an example. Using a database with a simple table with one row.
    A DBCC PAGE of the IAM page includes:
    PFS (1:1) = 0x70 IAM_PG MIXED_EXT ALLOCATED 0_PCT_FULL
    If I run the following:
    BEGIN
    TRANSACTION
    DROP
    TABLE T1
    GO
    And then do the DBCC PAGE again, the output now includes:
    PFS (1:1) = 0x30 IAM_PG MIXED_EXT 0_PCT_FULL
    And if I rollback then transaction, the DBCC PAGE output reverts to:
    PFS (1:1) = 0x70 IAM_PG MIXED_EXT ALLOCATED 0_PCT_FULL
    Thanks
    Saravana Kumar C

  • Logical reads per second

    I have two databases - one is a clone of the other, amde a few months ago. Database A has somewhat more data, since it's the active production database, but not significantly more - perhaps 10% greater. They are on different boxes. Database A is on a Sun 280R 2-processor box. Database B is on a Dell 2950 with 2 dual-core processors. So this isn't exactly comparing apples to apples. However, when I run the same query on the two databases, I get radically different results. Against Database A, the query takes about 7 minutes. On Database B, it takes about 2 seconds. Logical reads per second on Database A reach 80,000-90,000; on Database B, they're about 3,000. There are a few configuration differences (both databases use automatic memory management):
    Database A Database B
    db_file_multiblock_read_count 64 16
    log_buffer 14290432 2104832
    open_cursors 1250 300
    sga_max_size 4194304000 536870912
    sga_target 2634022912 536870912
    shared_pool_reserved_size 38587596 7340032
    The timings were taken off-hours so neither database would be busy. I'm baffled by the extreme difference in execution times. Any help appreciated!
    Thanks,
    Harry
    Edited by: harryb on Apr 8, 2009 7:26 PM

    OK, let's start here....
    Database A (TEMPOP)
    SQL> show parameter optimizer
    NAME TYPE VALUE
    optimizer_dynamic_sampling integer 2
    optimizer_features_enable string 10.2.0.3
    optimizer_index_caching integer 0
    optimizer_index_cost_adj integer 100
    optimizer_mode string ALL_ROWS
    optimizer_secure_view_merging boolean TRUE
    SQL> show parameter db_file_multi
    NAME TYPE VALUE
    db_file_multiblock_read_count integer 64
    SQL> show parameter db_block_size
    NAME TYPE VALUE
    db_block_size integer 8192
    ===================================================
    Database B (TEMPO11)
    SQL> show parameter optimizer
    NAME TYPE VALUE
    optimizer_dynamic_sampling integer 2
    optimizer_features_enable string 10.2.0.1
    optimizer_index_caching integer 0
    optimizer_index_cost_adj integer 100
    optimizer_mode string ALL_ROWS
    optimizer_secure_view_merging boolean TRUE
    SQL> show parameter db_file_multi
    NAME TYPE VALUE
    db_file_multiblock_read_count integer 16
    SQL> show parameter db_block_size
    NAME TYPE VALUE
    db_block_size integer 8192
    =================================================================
    Now for the query that's causing the problem:
    SELECT dsk_document_attribute.value_text inspect_permit_no,
              NVL (activity_task_list.revised_due_date,
                   activity_task_list.default_due_date
                 inspect_report_due_date,
              agency_interest.master_ai_id agency_interest_id,
              agency_interest.master_ai_name agency_interest_name,
              get_county_code_single (agency_interest.master_ai_id)
                 parish_or_county_code,
              agency_interest_address.physical_address_line_1 inspect_addr_1,
              agency_interest_address.physical_address_line_2 inspect_addr_2,
              agency_interest_address.physical_address_line_3 inspect_addr_3,
              agency_interest_address.physical_address_municipality inspect_city,
              agency_interest_address.physical_address_state_code state_id,
              agency_interest_address.physical_address_zip inspect_zip,
              person.master_person_first_name person_first_name,
              person.master_person_middle_initial person_middle_initial,
              person.master_person_last_name person__last_name,
              SUBSTR (person_telecom.address_or_phone, 1, 14) person_phone,
              activity_task_list.requirement_id
       FROM dsk_document_attribute,
            agency_interest,
            activity_task_list,
            agency_interest_address,
            dsk_central_file dsk_aaa,
            dsk_central_file dsk_frm,
            person,
            person_telecom
       WHERE agency_interest.int_doc_id = 0
             AND agency_interest.master_ai_id =
                   agency_interest_address.master_ai_id
             AND agency_interest.int_doc_id = agency_interest_address.int_doc_id
             AND agency_interest.master_ai_id = dsk_frm.master_ai_id
             AND dsk_aaa.int_doc_id = activity_task_list.int_doc_id
             AND dsk_frm.int_doc_id = dsk_document_attribute.int_doc_id
             AND dsk_frm.doc_type_specific_code =
                   dsk_document_attribute.doc_type_specific_code
             AND dsk_frm.activity_category_code = 'PER'
             AND dsk_frm.activity_class_code = 'GNP'
             AND dsk_frm.activity_type_code IN ('MAB', 'NAB', 'REB')
             AND dsk_frm.program_code = '80'
             AND dsk_frm.doc_type_general_code = 'FRM'
             AND dsk_frm.doc_type_specific_code = 'PERSET'
             AND dsk_aaa.doc_template_id = 2000
             AND dsk_frm.master_ai_id = dsk_aaa.master_ai_id
             AND dsk_frm.activity_category_code = dsk_aaa.activity_category_code
             AND dsk_frm.program_code = dsk_aaa.program_code
             AND dsk_frm.activity_class_code = dsk_aaa.activity_class_code
             AND dsk_frm.activity_type_code = dsk_aaa.activity_type_code
             AND dsk_frm.activity_year = dsk_aaa.activity_year
             AND dsk_frm.activity_num = dsk_aaa.activity_num
             AND dsk_document_attribute.doc_attribute_code = 'PERMIT_NO'
             AND activity_task_list.requirement_id IN ('3406', '3548', '3474')
             AND activity_task_list.reference_task_id = 0
             AND NVL (activity_task_list.status_code, '$$$') <> '%  '
             AND person.master_person_id(+) =
                   f_get_gp_contact (agency_interest.master_ai_id)
             AND person.int_doc_id(+) = 0
             AND person.master_person_id = person_telecom.master_person_id(+)
             AND person.int_doc_id = person_telecom.int_doc_id(+)
             AND person_telecom.telecom_type_code(+) = 'wp';Here's the explain plan for Database A, where the query takes 7-8 minutes or more:
    PLAN_TABLE_OUTPUT
    | Id  | Operation                           | Name                       | Rows  | Bytes | Cost (%CPU)|
    |   0 | SELECT STATEMENT                    |                            |     1 |   253 |    34   (3)|
    |   1 |  NESTED LOOPS                       |                            |     1 |   253 |    34   (3)|
    |   2 |   NESTED LOOPS                      |                            |     1 |   224 |    32   (0)|
    |   3 |    NESTED LOOPS OUTER               |                            |     1 |   169 |    31   (0)|
    |   4 |     NESTED LOOPS OUTER              |                            |     1 |   144 |    29   (0)|
    |   5 |      NESTED LOOPS                   |                            |     1 |   122 |    27   (0)|
    |   6 |       NESTED LOOPS                  |                            |     1 |    81 |    26   (0)|
    PLAN_TABLE_OUTPUT
    |   7 |        NESTED LOOPS                 |                            |     1 |    48 |    19   (0)|
    |   8 |         INLIST ITERATOR             |                            |       |       |            |
    |*  9 |          TABLE ACCESS BY INDEX ROWID| ACTIVITY_TASK_LIST         |     1 |    21 |    17   (0)|
    |* 10 |           INDEX RANGE SCAN          | ACTIVITY_TASK_LIST_FK11    |   106 |       |     4   (0)|
    |* 11 |         TABLE ACCESS BY INDEX ROWID | DSK_CENTRAL_FILE           |     1 |    27 |     2   (0)|
    |* 12 |          INDEX UNIQUE SCAN          | PK_DSK_CENTRAL_FILE        |     1 |       |     1   (0)|
    |* 13 |        TABLE ACCESS BY INDEX ROWID  | DSK_CENTRAL_FILE           |     1 |    33 |     7   (0)|
    |* 14 |         INDEX RANGE SCAN            | CF_MASTER_AI_ID_IND        |     9 |       |     2   (0)|
    |  15 |       TABLE ACCESS BY INDEX ROWID   | AGENCY_INTEREST            |     1 |    41 |     1   (0)|
    |* 16 |        INDEX UNIQUE SCAN            | PK_AGENCY_INTEREST         |     1 |       |     0   (0)|
    |  17 |      TABLE ACCESS BY INDEX ROWID    | PERSON                     |     1 |    22 |     2   (0)|
    PLAN_TABLE_OUTPUT
    |* 18 |       INDEX UNIQUE SCAN             | PK_PERSON                  |     1 |       |     1   (0)|
    |  19 |     TABLE ACCESS BY INDEX ROWID     | PERSON_TELECOM             |     1 |    25 |     2   (0)|
    |* 20 |      INDEX UNIQUE SCAN              | PK_PERSON_TELECOM          |     1 |       |     1   (0)|
    |  21 |    TABLE ACCESS BY INDEX ROWID      | AGENCY_INTEREST_ADDRESS    |     1 |    55 |     1   (0)|
    |* 22 |     INDEX UNIQUE SCAN               | PK_AGENCY_INTEREST_ADDRESS |     1 |       |     0   (0)|
    |  23 |   TABLE ACCESS BY INDEX ROWID       | DSK_DOCUMENT_ATTRIBUTE     |     1 |    29 |     1   (0)|
    |* 24 |    INDEX UNIQUE SCAN                | PK_DSK_DOCUMENT_ATTRIBUTE  |     1 |       |     0   (0)|
    Predicate Information (identified by operation id):
    PLAN_TABLE_OUTPUT
       9 - filter("ACTIVITY_TASK_LIST"."REFERENCE_TASK_ID"=0 AND
                  NVL("ACTIVITY_TASK_LIST"."STATUS_CODE",'$$$')<>'%  ')
      10 - access("ACTIVITY_TASK_LIST"."REQUIREMENT_ID"=3406 OR
                  "ACTIVITY_TASK_LIST"."REQUIREMENT_ID"=3474 OR "ACTIVITY_TASK_LIST"."REQUIREMENT_ID"=3548)
      11 - filter("DSK_AAA"."DOC_TEMPLATE_ID"=2000 AND "DSK_AAA"."ACTIVITY_CLASS_CODE"='GNP' AND
                  "DSK_AAA"."PROGRAM_CODE"='80' AND "DSK_AAA"."ACTIVITY_CATEGORY_CODE"='PER' AND
                  ("DSK_AAA"."ACTIVITY_TYPE_CODE"='MAB' OR "DSK_AAA"."ACTIVITY_TYPE_CODE"='NAB' OR
                  "DSK_AAA"."ACTIVITY_TYPE_CODE"='REB'))
      12 - access("ACTIVITY_TASK_LIST"."INT_DOC_ID"="DSK_AAA"."INT_DOC_ID")
      13 - filter("DSK_FRM"."ACTIVITY_CLASS_CODE"='GNP' AND "DSK_FRM"."PROGRAM_CODE"='80' AND
    PLAN_TABLE_OUTPUT
                  "DSK_FRM"."DOC_TYPE_SPECIFIC_CODE"='PERSET' AND "DSK_FRM"."ACTIVITY_CATEGORY_CODE"='PER' AND
                  "DSK_FRM"."DOC_TYPE_GENERAL_CODE"='FRM' AND ("DSK_FRM"."ACTIVITY_TYPE_CODE"='MAB' OR
                  "DSK_FRM"."ACTIVITY_TYPE_CODE"='NAB' OR "DSK_FRM"."ACTIVITY_TYPE_CODE"='REB') AND
                  "DSK_FRM"."ACTIVITY_TYPE_CODE"="DSK_AAA"."ACTIVITY_TYPE_CODE" AND
                  "DSK_FRM"."ACTIVITY_YEAR"="DSK_AAA"."ACTIVITY_YEAR" AND
                  "DSK_FRM"."ACTIVITY_NUM"="DSK_AAA"."ACTIVITY_NUM")
      14 - access("DSK_FRM"."MASTER_AI_ID"="DSK_AAA"."MASTER_AI_ID")
      16 - access("AGENCY_INTEREST"."MASTER_AI_ID"="DSK_FRM"."MASTER_AI_ID" AND
                  "AGENCY_INTEREST"."INT_DOC_ID"=0)
      18 - access("PERSON"."MASTER_PERSON_ID"(+)="F_GET_GP_CONTACT"("AGENCY_INTEREST"."MASTER_AI_ID
                  ") AND "PERSON"."INT_DOC_ID"(+)=0)
    PLAN_TABLE_OUTPUT
      20 - access("PERSON"."MASTER_PERSON_ID"="PERSON_TELECOM"."MASTER_PERSON_ID"(+) AND
                  "PERSON_TELECOM"."TELECOM_TYPE_CODE"(+)='wp' AND
                  "PERSON"."INT_DOC_ID"="PERSON_TELECOM"."INT_DOC_ID"(+))
      22 - access("AGENCY_INTEREST"."MASTER_AI_ID"="AGENCY_INTEREST_ADDRESS"."MASTER_AI_ID" AND
                  "AGENCY_INTEREST_ADDRESS"."INT_DOC_ID"=0)
      24 - access("DSK_FRM"."INT_DOC_ID"="DSK_DOCUMENT_ATTRIBUTE"."INT_DOC_ID" AND
                  "DSK_DOCUMENT_ATTRIBUTE"."DOC_ATTRIBUTE_CODE"='PERMIT_NO' AND
                  "DSK_DOCUMENT_ATTRIBUTE"."DOC_TYPE_SPECIFIC_CODE"='PERSET')============================================================================
    Here's the explan plan output for Database B, where the query takes 2-3 seconds:
    PLAN_TABLE_OUTPUT
    | Id  | Operation                           | Name                       | Rows  | Bytes | Cost (%CPU)|
    |   0 | SELECT STATEMENT                    |                            |     1 |   289 |    39   (0)|
    |   1 |  NESTED LOOPS OUTER                 |                            |     1 |   289 |    39   (0)|
    |   2 |   NESTED LOOPS                      |                            |     1 |   260 |    37   (0)|
    |   3 |    NESTED LOOPS                     |                            |     1 |   205 |    36   (0)|
    |   4 |     NESTED LOOPS OUTER              |                            |     1 |   172 |    35   (0)|
    |   5 |      NESTED LOOPS                   |                            |     1 |   145 |    34   (0)|
    |   6 |       NESTED LOOPS                  |                            |     1 |   104 |    33   (0)|
    PLAN_TABLE_OUTPUT
    |   7 |        NESTED LOOPS                 |                            |     1 |    61 |    26   (0)|
    |   8 |         INLIST ITERATOR             |                            |       |       |            |
    |*  9 |          TABLE ACCESS BY INDEX ROWID| ACTIVITY_TASK_LIST         |     1 |    25 |    24   (0)|
    |* 10 |           INDEX RANGE SCAN          | ACTIVITY_TASK_LIST_FK11    |   145 |       |     4   (0)|
    |* 11 |         TABLE ACCESS BY INDEX ROWID | DSK_CENTRAL_FILE           |     1 |    36 |     2   (0)|
    |* 12 |          INDEX UNIQUE SCAN          | PK_DSK_CENTRAL_FILE        |     1 |       |     1   (0)|
    |* 13 |        TABLE ACCESS BY INDEX ROWID  | DSK_CENTRAL_FILE           |     1 |    43 |     7   (0)|
    |* 14 |         INDEX RANGE SCAN            | CF_MASTER_AI_ID_IND        |     9 |       |     2   (0)|
    |  15 |       TABLE ACCESS BY INDEX ROWID   | AGENCY_INTEREST            |     1 |    41 |     1   (0)|
    |* 16 |        INDEX UNIQUE SCAN            | PK_AGENCY_INTEREST         |     1 |       |     0   (0)|
    |  17 |      TABLE ACCESS BY INDEX ROWID    | PERSON                     |     8 |   216 |     1   (0)|
    PLAN_TABLE_OUTPUT
    |* 18 |       INDEX UNIQUE SCAN             | PK_PERSON                  |     1 |       |     0   (0)|
    |  19 |     TABLE ACCESS BY INDEX ROWID     | DSK_DOCUMENT_ATTRIBUTE     |     1 |    33 |     1   (0)|
    |* 20 |      INDEX UNIQUE SCAN              | PK_DSK_DOCUMENT_ATTRIBUTE  |     1 |       |     0   (0)|
    |  21 |    TABLE ACCESS BY INDEX ROWID      | AGENCY_INTEREST_ADDRESS    |     1 |    55 |     1   (0)|
    |* 22 |     INDEX UNIQUE SCAN               | PK_AGENCY_INTEREST_ADDRESS |     1 |       |     0   (0)|
    |  23 |   TABLE ACCESS BY INDEX ROWID       | PERSON_TELECOM             |     1 |    29 |     2   (0)|
    |* 24 |    INDEX UNIQUE SCAN                | PK_PERSON_TELECOM          |     1 |       |     1   (0)|
    Predicate Information (identified by operation id):
    PLAN_TABLE_OUTPUT
       9 - filter("ACTIVITY_TASK_LIST"."REFERENCE_TASK_ID"=0 AND
                  NVL("ACTIVITY_TASK_LIST"."STATUS_CODE",'$$$')<>'%  ')
      10 - access("ACTIVITY_TASK_LIST"."REQUIREMENT_ID"=3406 OR
                  "ACTIVITY_TASK_LIST"."REQUIREMENT_ID"=3474 OR "ACTIVITY_TASK_LIST"."REQUIREMENT_ID"=3548)
      11 - filter("DSK_AAA"."DOC_TEMPLATE_ID"=2000 AND "DSK_AAA"."ACTIVITY_CLASS_CODE"='GNP' AND
                  "DSK_AAA"."PROGRAM_CODE"='80' AND "DSK_AAA"."ACTIVITY_CATEGORY_CODE"='PER' AND
                  ("DSK_AAA"."ACTIVITY_TYPE_CODE"='MAB' OR "DSK_AAA"."ACTIVITY_TYPE_CODE"='NAB' OR
                  "DSK_AAA"."ACTIVITY_TYPE_CODE"='REB'))
      12 - access("ACTIVITY_TASK_LIST"."INT_DOC_ID"="DSK_AAA"."INT_DOC_ID")
      13 - filter("DSK_FRM"."DOC_TYPE_SPECIFIC_CODE"='PERSET' AND
    PLAN_TABLE_OUTPUT
                  "DSK_FRM"."ACTIVITY_CLASS_CODE"='GNP' AND "DSK_FRM"."PROGRAM_CODE"='80' AND
                  "DSK_FRM"."DOC_TYPE_GENERAL_CODE"='FRM' AND "DSK_FRM"."ACTIVITY_CATEGORY_CODE"='PER' AND
                  ("DSK_FRM"."ACTIVITY_TYPE_CODE"='MAB' OR "DSK_FRM"."ACTIVITY_TYPE_CODE"='NAB' OR
                  "DSK_FRM"."ACTIVITY_TYPE_CODE"='REB') AND "DSK_FRM"."ACTIVITY_TYPE_CODE"="DSK_AAA"."ACTIVITY_TY
                  PE_CODE" AND "DSK_FRM"."ACTIVITY_YEAR"="DSK_AAA"."ACTIVITY_YEAR" AND
                  "DSK_FRM"."ACTIVITY_NUM"="DSK_AAA"."ACTIVITY_NUM")
      14 - access("DSK_FRM"."MASTER_AI_ID"="DSK_AAA"."MASTER_AI_ID")
      16 - access("AGENCY_INTEREST"."MASTER_AI_ID"="DSK_FRM"."MASTER_AI_ID" AND
                  "AGENCY_INTEREST"."INT_DOC_ID"=0)
      18 - access("PERSON"."MASTER_PERSON_ID"(+)="F_GET_GP_CONTACT"("AGENCY_INTEREST"."MASTER_AI_ID
                  ") AND "PERSON"."INT_DOC_ID"(+)=0)
    PLAN_TABLE_OUTPUT
      20 - access("DSK_FRM"."INT_DOC_ID"="DSK_DOCUMENT_ATTRIBUTE"."INT_DOC_ID" AND
                  "DSK_DOCUMENT_ATTRIBUTE"."DOC_ATTRIBUTE_CODE"='PERMIT_NO' AND
                  "DSK_DOCUMENT_ATTRIBUTE"."DOC_TYPE_SPECIFIC_CODE"='PERSET')
      22 - access("AGENCY_INTEREST"."MASTER_AI_ID"="AGENCY_INTEREST_ADDRESS"."MASTER_AI_ID" AND
                  "AGENCY_INTEREST_ADDRESS"."INT_DOC_ID"=0)
      24 - access("PERSON"."MASTER_PERSON_ID"="PERSON_TELECOM"."MASTER_PERSON_ID"(+) AND
                  "PERSON_TELECOM"."TELECOM_TYPE_CODE"(+)='wp' AND
                  "PERSON"."INT_DOC_ID"="PERSON_TELECOM"."INT_DOC_ID"(+))===============================================================================
    Edited by: harryb on Apr 9, 2009 3:29 PM

  • Plan shows SQL execution time Hrs 999:59:59 Sec.

    Dear Masters,
    Today my development team reported that the below query is taking more time. When I check the plan for my shok it is showing Hrs 999:59:59 Sec.
    Kindly help me in tuning this query.
    I am using oracle 10.2.0.3 version.
    SELECT 
    S_INVLOC.NAME , S_ORDER.ACCNT_ID , S_ORDER.APPR_BY_EMP_ID , S_ORDER.BL_CON_ID , S_ORDER.BL_OU_ID , S_ORDER.CARRIER_CD , S_ORDER.CONTACT_ID , S_ORDER.CURCY_CD , S_ORDER.TAX_EXEMPT_FLG ,
    S_ORDER.REQ_SHIP_DT , S_ORDER.SHIP_ADDR_ID , S_ORDER.SHIP_CON_ID , S_ORDER.SHIP_METH_CD , S_ORDER.SHIP_OU_ID , S_ORDER.STATUS_CD , S_ORDER.TAX_EXEMPT_NUM , S_ORDER.TAX_EXEMPT_REASON ,
    S_ORDER.OPTY_ID , S_ORDER.BU_ID PR_VIS_ORG_ID , S_ORDER.PROMO_ID , S_ORDER.PRI_LST_ID , S_ORDER.AGREE_ID AGREEMENT_ID , S_ORDER.ENTLMNT_ID ENTITLEMENT_ID , S_ORDER.SR_ID ,
    S_ORDER.BILLABLE_FLG , S_ORDER_ITEM.ROW_ID , S_ORDER_ITEM.ORDER_ID , S_ORDER_ITEM.LN_NUM , S_ORDER_ITEM.PROD_ID , S_ORDER_ITEM.ADJ_UNIT_PRI , S_ORDER_ITEM.BASE_UNIT_PRI ,
    S_ORDER_ITEM.CARRIER_CD CARRIER_CD1 , S_ORDER_ITEM.EXTD_QTY , S_ORDER_ITEM.QTY_SHIPPED , S_ORDER_ITEM.REQ_SHIP_DT REQ_SHIP_DT1 , S_ORDER_ITEM.SHIP_ADDR_ID SHIP_ADDR_ID1 ,
    S_ORDER_ITEM.SHIP_CON_ID SHIP_CON_ID1 , S_ORDER_ITEM.SHIP_METH_CD SHIP_METH_CD1 , S_ORDER_ITEM.STATUS_CD STATUS_CD1 , S_ORDER_ITEM.PROD_STATUS_CD , S_ORDER_ITEM.PROD_NAME ,
    S_ORDER_ITEM.LOANER_FLG , S_ORDER_ITEM.DISCNT_METH_CD , S_ORDER_ITEM.SHIP_OU_ID SHIP_OU_ID1 , S_ORDER_ITEM.STATUS_DT , S_ORDER_ITEM.MUST_DLVR_BY_DT , S_ORDER_ITEM.ACTION_CD ,
    S_ORDER_ITEM.ROLLUP_PRI , S_PROD_INT.NAME NAME1 , A.NAME NAME2 , B.NAME NAME3 , S_VOL_DISCNT.NAME NAME4 , ACCNT.PR_INDUST_ID , POSCRTDORG.OU_ID CREATED_BY_ORG_ID ,
    POSOWNERORG.OU_ID PR_OWNER_ORG_ID , PAROITEM.LN_NUM , PAROITEM.PROD_ID , SHIPOITEM.CITY , SHIPOITEM.COUNTRY , SHIPOITEM.ZIPCODE , SHIPO.CITY , SHIPO.COUNTRY , SHIPO.ZIPCODE ,
    BILL.CITY , BILL.COUNTRY , BILL.ZIPCODE , S_CAMP_CON.PR_CALL_LST_ID SEGMENT_ID , S_ORDER.DCP_ID OFFER_ID , APPRBYPOS.PR_HELD_POSTN_ID , POSOWNERORG.ROW_ID , POSOWNERORG.PR_EMP_ID ,
    S_ENTLMNT.PAR_AGREE_ID , ROOTOITEM.PROD_ID ROOT_LN_PROD_ID , ROOTOITEM.LN_NUM ROOT_LN_NUM , S_ORDER.PR_POSTN_ID , S_CAMP_CON.CAMP_LD_WAVE_ID , S_SRC.REGION_ID , OPRI.COST_PRI ,
    S_ORDER_ITEM.ORDER_ITM_CURCY_CD OITM_CURCY_CD , ROOTOITEM.ORDER_ITM_CURCY_CD ROOTOITM_CURCY_CD , S_ORDER_ITEM.ORDER_ITM_EXCH_DT OITM_AMT_DT , S_ORDER.ORDER_EXCH_DT ,
    S_ORDER_ITEM.CREATED , S_ORDER_ITEM.NET_PRI , S_ORDER_ITEM.CRSE_OFFR_ID , S_ORDER_ITEM.PRI_LST_ID OITM_PRI_LST_ID , ROOTOITEM.PRI_LST_ID ROOTOITM_PRI_LST_ID ,
    OWNORG.PRTNR_FLG , VISORG.PRTNR_FLG , S_CAMP_LD_WAVE.LAUNCHED_TS , QUOTE.CREATED , S_ORDER.ACTIVE_FLG , S_ORDER.APPROVED_FLG , PARPROD.PROD_TYPE_CD , ROOTPROD.PROD_TYPE_CD ,
    S_PROD_INT.PRICE_TYPE_CD , S_SRC.PROG_END_DT , S_SRC.PROG_START_DT , S_SRC.ROW_ID , S_ORDER.CREATED , OWNORG.ROW_ID , 0 AS X_CUSTOM , S_ORDER_ITEM. X_PHONE_NUMBER ,
    S_ORDER_ITEM.X_BACKEND_SERVICE_ID , S_ORDER_ITEM.SERVICE_NUM , S_ORDER_ITEM.BILL_ACCNT_ID , S_ORDER_X.ATTRIB_04 , S_ORDER_X.ATTRIB_30 , S_ORDER_X.ATTRIB_31
       FROM
    SIEBEL.V_ORDER_ITEM S_ORDER_ITEM, SIEBEL.S_ORDER_ITEM PAROITEM, SIEBEL.S_ORDER_ITEM ROOTOITEM, SIEBEL.S_ORDER, SIEBEL.S_VDISCNT_ITEM A, SIEBEL.S_VOL_DISCNT, SIEBEL.S_PROD_INT,
    SIEBEL.S_VDISCNT_ITEM B, SIEBEL.S_INVLOC, SIEBEL.S_ORG_EXT ACCNT, SIEBEL.S_POSTN POSOWNERORG, SIEBEL.S_CONTACT CRTD, SIEBEL.S_CONTACT APPRBYPOS, SIEBEL.S_POSTN POSCRTDORG,
    SIEBEL.S_ADDR_ORG SHIPOITEM, SIEBEL.S_ADDR_ORG SHIPO, SIEBEL.S_ADDR_ORG BILL, SIEBEL.S_CAMP_CON, SIEBEL.S_ENTLMNT, SIEBEL.S_SRC, SIEBEL.S_ORDER_ITM_PRI OPRI,
    SIEBEL.S_CAMP_LD_WAVE, SIEBEL.S_DOC_QUOTE QUOTE, SIEBEL.S_ORG_EXT OWNORG, SIEBEL.S_ORG_EXT OWNORG1, SIEBEL.S_ORG_EXT VISORG1, SIEBEL.S_ORG_EXT VISORG,
    SIEBEL.S_PROD_INT PARPROD, SIEBEL.S_PROD_INT ROOTPROD, SIEBEL.S_ORDER_X
    WHERE
         S_ORDER_ITEM.ORDER_ID     = S_ORDER.ROW_ID
        AND S_ORDER_ITEM.ROOT_ORDER_ITEM_ID  = ROOTOITEM.ROW_ID
        AND S_ORDER_ITEM.PAR_ORDER_ITEM_ID   = PAROITEM.ROW_ID(+)
        AND S_ORDER_ITEM.PROD_ID      = S_PROD_INT.ROW_ID(+)
        AND S_ORDER_ITEM.SRC_INVLOC_ID       = S_INVLOC.ROW_ID(+)
        AND S_ORDER_ITEM.VOL_DISCNT_ITEM_ID  = A.ROW_ID(+)
        AND S_ORDER_ITEM.VOL_DISCNT_ID       = S_VOL_DISCNT.ROW_ID(+)
        AND S_ORDER_ITEM.VOL_UPSELL_ITEM_ID  = B.ROW_ID(+)
        AND S_ORDER_ITEM.SHIP_ADDR_ID = SHIPOITEM.ROW_ID(+)
        AND S_ORDER.PR_POSTN_ID       = POSOWNERORG.ROW_ID(+)
        AND S_ORDER_ITEM.CREATED_BY   = CRTD.ROW_ID(+)
        AND CRTD.PR_HELD_POSTN_ID     = POSCRTDORG.ROW_ID(+)
        AND S_ORDER.ACCNT_ID   = ACCNT.ROW_ID(+)
        AND S_ORDER.CAMP_CON_ID       = S_CAMP_CON.ROW_ID(+)
        AND S_ORDER.SHIP_ADDR_ID      = SHIPO.ROW_ID(+)
        AND S_ORDER.BL_ADDR_ID        = BILL.ROW_ID(+)
        AND S_ORDER.APPR_BY_EMP_ID    = APPRBYPOS.ROW_ID(+)
        AND S_ORDER.ENTLMNT_ID        = S_ENTLMNT.ROW_ID(+)
        AND S_ORDER.PROMO_ID   = S_SRC.ROW_ID(+)
        AND S_ORDER_ITEM.ROW_ID       = OPRI.PAR_ROW_ID(+)
        AND S_CAMP_CON.CAMP_LD_WAVE_ID       = S_CAMP_LD_WAVE.ROW_ID(+)
        AND S_ORDER.QUOTE_ID   = QUOTE.ROW_ID(+)
        AND POSOWNERORG.OU_ID  = OWNORG1.ROW_ID(+)
        AND OWNORG1.PAR_BU_ID  = OWNORG.ROW_ID(+)
        AND S_ORDER.BU_ID      = VISORG1.ROW_ID(+)
        AND VISORG1.PAR_BU_ID  = VISORG.ROW_ID(+)
        AND PAROITEM.PROD_ID   = PARPROD.ROW_ID(+)
        AND ROOTOITEM.PROD_ID  = ROOTPROD.ROW_ID(+)
        AND S_ORDER_ITEM.ORDER_ID     = S_ORDER_X.PAR_ROW_ID(+)
        AND S_ORDER_ITEM.ROOT_ORDER_ITEM_ID IS NOT NULL;Execution Plan is : select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 73463824
    | Id  | Operation                                                | Name              | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                                         |                   |  3170K|    12G|  4100G  (4)|999:59:59 |
    |   1 |  NESTED LOOPS OUTER                                      |                   |  3170K|    12G|  4100G  (4)|999:59:59 |
    |   2 |   NESTED LOOPS OUTER                                     |                   |  3170K|    12G|  4100G  (4)|999:59:59 |
    |   3 |    NESTED LOOPS OUTER                                    |                   |  3170K|    12G|  4100G  (4)|999:59:59 |
    |   4 |     NESTED LOOPS OUTER                                   |                   |  3170K|    12G|  4100G  (4)|999:59:59 |
    |   5 |      NESTED LOOPS OUTER                                  |                   |  3170K|    12G|  4100G  (4)|999:59:59 |
    |   6 |       NESTED LOOPS                                       |                   |  3170K|    12G|  4100G  (4)|999:59:59 |
    |   7 |        NESTED LOOPS OUTER                                |                   |  3170K|    12G|  4100G  (4)|999:59:59 |
    |   8 |         NESTED LOOPS OUTER                               |                   |  3170K|    12G|  4100G  (4)|999:59:59 |
    |   9 |          NESTED LOOPS OUTER                              |                   |  3170K|    12G|  4100G  (4)|999:59:59 |
    |  10 |           NESTED LOOPS OUTER                             |                   |  3170K|    12G|  4100G  (4)|999:59:59 |
    |  11 |            NESTED LOOPS OUTER                            |                   |  3170K|    12G|  4100G  (4)|999:59:59 |
    |  12 |             NESTED LOOPS OUTER                           |                   |  3170K|    12G|  4100G  (4)|999:59:59 |
    |  13 |              NESTED LOOPS OUTER                          |                   |  3170K|    12G|  4100G  (4)|999:59:59 |
    |  14 |               NESTED LOOPS OUTER                         |                   |  3170K|    12G|  4100G  (4)|999:59:59 |
    |  15 |                NESTED LOOPS OUTER                        |                   |  3170K|    11G|  4100G  (4)|999:59:59 |
    |  16 |                 NESTED LOOPS OUTER                       |                   |  3170K|    11G|  4100G  (4)|999:59:59 |
    |  17 |                  NESTED LOOPS OUTER                      |                   |  3170K|    11G|  4100G  (4)|999:59:59 |
    |  18 |                   NESTED LOOPS OUTER                     |                   |  3170K|    10G|  4100G  (4)|999:59:59 |
    |  19 |                    NESTED LOOPS OUTER                    |                   |  3170K|    10G|  4100G  (4)|999:59:59 |
    |  20 |                     NESTED LOOPS OUTER                   |                   |  3170K|    10G|  4100G  (4)|999:59:59 |
    |  21 |                      NESTED LOOPS                        |                   |  3170K|  9911M|  4100G  (4)|999:59:59 |
    |  22 |                       NESTED LOOPS OUTER                 |                   |  3108K|  4927M|  2569K  (2)| 01:08:47 |
    |  23 |                        NESTED LOOPS OUTER                |                   |  3108K|  4835M|   115K (14)| 00:03:06 |
    |  24 |                         NESTED LOOPS OUTER               |                   |  3108K|  4782M|   115K (14)| 00:03:06 |
    |  25 |                          NESTED LOOPS OUTER              |                   |  3108K|  4660M|   112K (12)| 00:03:02 |
    |  26 |                           NESTED LOOPS OUTER             |                   |  3108K|  4417M|   112K (12)| 00:03:02 |
    |  27 |                            NESTED LOOPS OUTER            |                   |  3108K|  4227M|   112K (12)| 00:03:02 |
    |  28 |                             NESTED LOOPS OUTER           |                   |  3108K|  3943M|   112K (12)| 00:03:02 |
    |  29 |                              NESTED LOOPS OUTER          |                   |  3108K|  3178M|   111K (11)| 00:02:59 |
    |  30 |                               TABLE ACCESS FULL          | S_ORDER           |  3108K|  2413M|   109K  (9)| 00:02:56 |
    |  31 |                               TABLE ACCESS BY INDEX ROWID| S_ADDR_ORG        |     1 |   258 |     1   (0)| 00:00:01 |
    |* 32 |                                INDEX UNIQUE SCAN         | S_ADDR_ORG_P1     |     1 |       |     1   (0)| 00:00:01 |
    |  33 |                              TABLE ACCESS BY INDEX ROWID | S_ADDR_ORG        |     1 |   258 |     1   (0)| 00:00:01 |
    |* 34 |                               INDEX UNIQUE SCAN          | S_ADDR_ORG_P1     |     1 |       |     1   (0)| 00:00:01 |
    |  35 |                             TABLE ACCESS BY INDEX ROWID  | S_CAMP_CON        |     1 |    96 |     1   (0)| 00:00:01 |
    |* 36 |                              INDEX UNIQUE SCAN           | S_CAMP_CON_P1     |     1 |       |     1   (0)| 00:00:01 |
    |  37 |                            TABLE ACCESS BY INDEX ROWID   | S_ENTLMNT         |     1 |    64 |     1   (0)| 00:00:01 |
    |* 38 |                             INDEX UNIQUE SCAN            | S_ENTLMNT_P1      |     1 |       |     1   (0)| 00:00:01 |
    |  39 |                           TABLE ACCESS BY INDEX ROWID    | S_SRC             |     1 |    82 |     1   (0)| 00:00:01 |
    |* 40 |                            INDEX UNIQUE SCAN             | S_SRC_P1          |     1 |       |     1   (0)| 00:00:01 |
    |  41 |                          TABLE ACCESS BY INDEX ROWID     | S_CAMP_LD_WAVE    |     1 |    41 |     1   (0)| 00:00:01 |
    |* 42 |                           INDEX UNIQUE SCAN              | S_CAMP_LD_WAVE_P1 |     1 |       |     1   (0)| 00:00:01 |
    |  43 |                         TABLE ACCESS BY INDEX ROWID      | S_DOC_QUOTE       |     1 |    18 |     1   (0)| 00:00:01 |
    |* 44 |                          INDEX UNIQUE SCAN               | S_DOC_QUOTE_P1    |     1 |       |     1   (0)| 00:00:01 |
    |  45 |                        TABLE ACCESS BY INDEX ROWID       | S_POSTN           |     1 |    31 |     1   (0)| 00:00:01 |
    |* 46 |                         INDEX UNIQUE SCAN                | S_POSTN_P1        |     1 |       |     1   (0)| 00:00:01 |
    |* 47 |                       VIEW                               | V_ORDER_ITEM      |     1 |  1616 |  1318K  (4)| 00:35:19 |
    |  48 |                        NESTED LOOPS                      |                   |  3128K|  1372M|  1318K  (4)| 00:35:19 |
    |  49 |                         INDEX FAST FULL SCAN             | S_ETL_I_IMG_25_M2 |  3128K|    32M|  2756  (11)| 00:00:05 |
    |* 50 |                         TABLE ACCESS BY INDEX ROWID      | S_ORDER_ITEM      |     1 |   449 |     2   (0)| 00:00:01 |
    |* 51 |                          INDEX UNIQUE SCAN               | S_ORDER_ITEM_P1   |     1 |       |     2   (0)| 00:00:01 |
    |  52 |                      TABLE ACCESS BY INDEX ROWID         | S_VDISCNT_ITEM    |     1 |   134 |     1   (0)| 00:00:01 |
    |* 53 |                       INDEX UNIQUE SCAN                  | S_VDISCNT_ITEM_P1 |     1 |       |     1   (0)| 00:00:01 |
    |  54 |                     TABLE ACCESS BY INDEX ROWID          | S_VOL_DISCNT      |     1 |   134 |     1   (0)| 00:00:01 |
    |* 55 |                      INDEX UNIQUE SCAN                   | S_VOL_DISCNT_P1   |     1 |       |     1   (0)| 00:00:01 |
    |  56 |                    TABLE ACCESS BY INDEX ROWID           | S_VDISCNT_ITEM    |     1 |   134 |     1   (0)| 00:00:01 |
    |* 57 |                     INDEX UNIQUE SCAN                    | S_VDISCNT_ITEM_P1 |     1 |       |     1   (0)| 00:00:01 |
    |  58 |                   TABLE ACCESS BY INDEX ROWID            | S_ADDR_ORG        |     1 |   258 |     1   (0)| 00:00:01 |
    |* 59 |                    INDEX UNIQUE SCAN                     | S_ADDR_ORG_P1     |     1 |       |     1   (0)| 00:00:01 |
    |* 60 |                  TABLE ACCESS FULL                       | S_ORDER_ITM_PRI   |     1 |    45 |     0   (0)| 00:00:01 |
    |  61 |                 TABLE ACCESS BY INDEX ROWID              | S_INVLOC          |     1 |    33 |     1   (0)| 00:00:01 |
    |* 62 |                  INDEX UNIQUE SCAN                       | S_INVLOC_P1       |     1 |       |     1   (0)| 00:00:01 |
    |  63 |                TABLE ACCESS BY INDEX ROWID               | S_PROD_INT        |     1 |    58 |     1   (0)| 00:00:01 |
    |* 64 |                 INDEX UNIQUE SCAN                        | S_PROD_INT_P1     |     1 |       |     1   (0)| 00:00:01 |
    |  65 |               TABLE ACCESS BY INDEX ROWID                | S_ORDER_X         |     1 |    36 |     2   (0)| 00:00:01 |
    |* 66 |                INDEX RANGE SCAN                          | S_ORDER_X_U1      |     1 |       |     2   (0)| 00:00:01 |
    |  67 |              TABLE ACCESS BY INDEX ROWID                 | S_CONTACT         |     1 |    14 |     2   (0)| 00:00:01 |
    |* 68 |               INDEX UNIQUE SCAN                          | S_CONTACT_P1      |     1 |       |     1   (0)| 00:00:01 |
    |  69 |             TABLE ACCESS BY INDEX ROWID                  | S_POSTN           |     1 |    20 |     1   (0)| 00:00:01 |
    |* 70 |              INDEX UNIQUE SCAN                           | S_POSTN_P1        |     1 |       |     1   (0)| 00:00:01 |
    |  71 |            TABLE ACCESS BY INDEX ROWID                   | S_CONTACT         |     1 |    14 |     1   (0)| 00:00:01 |
    |* 72 |             INDEX UNIQUE SCAN                            | S_CONTACT_P1      |     1 |       |     1   (0)| 00:00:01 |
    |  73 |           TABLE ACCESS BY INDEX ROWID                    | S_ORG_EXT         |     1 |    14 |     2   (0)| 00:00:01 |
    |* 74 |            INDEX UNIQUE SCAN                             | S_ORG_EXT_P1      |     1 |       |     1   (0)| 00:00:01 |
    |  75 |          TABLE ACCESS BY INDEX ROWID                     | S_ORG_EXT         |     1 |    14 |     2   (0)| 00:00:01 |
    |* 76 |           INDEX UNIQUE SCAN                              | S_ORG_EXT_P1      |     1 |       |     1   (0)| 00:00:01 |
    |  77 |         TABLE ACCESS BY INDEX ROWID                      | S_ORG_EXT         |     1 |    17 |     2   (0)| 00:00:01 |
    |* 78 |          INDEX UNIQUE SCAN                               | S_ORG_EXT_P1      |     1 |       |     1   (0)| 00:00:01 |
    |  79 |        TABLE ACCESS BY INDEX ROWID                       | S_ORDER_ITEM      |     1 |    60 |     2   (0)| 00:00:01 |
    |* 80 |         INDEX UNIQUE SCAN                                | S_ORDER_ITEM_P1   |     1 |       |     2   (0)| 00:00:01 |
    |  81 |       TABLE ACCESS BY INDEX ROWID                        | S_ORDER_ITEM      |     1 |    24 |     2   (0)| 00:00:01 |
    |* 82 |        INDEX UNIQUE SCAN                                 | S_ORDER_ITEM_P1   |     1 |       |     2   (0)| 00:00:01 |
    |  83 |      TABLE ACCESS BY INDEX ROWID                         | S_PROD_INT        |     1 |    16 |     1   (0)| 00:00:01 |
    |* 84 |       INDEX UNIQUE SCAN                                  | S_PROD_INT_P1     |     1 |       |     1   (0)| 00:00:01 |
    |  85 |     TABLE ACCESS BY INDEX ROWID                          | S_PROD_INT        |     1 |    16 |     1   (0)| 00:00:01 |
    |* 86 |      INDEX UNIQUE SCAN                                   | S_PROD_INT_P1     |     1 |       |     1   (0)| 00:00:01 |
    |  87 |    TABLE ACCESS BY INDEX ROWID                           | S_ORG_EXT         |     1 |    14 |     2   (0)| 00:00:01 |
    |* 88 |     INDEX UNIQUE SCAN                                    | S_ORG_EXT_P1      |     1 |       |     1   (0)| 00:00:01 |
    |  89 |   TABLE ACCESS BY INDEX ROWID                            | S_ORG_EXT         |     1 |    17 |     2   (0)| 00:00:01 |
    |* 90 |    INDEX UNIQUE SCAN                                     | S_ORG_EXT_P1      |     1 |       |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
      32 - access("S_ORDER"."SHIP_ADDR_ID"="SHIPO"."ROW_ID"(+))
      34 - access("S_ORDER"."BL_ADDR_ID"="BILL"."ROW_ID"(+))
      36 - access("S_ORDER"."CAMP_CON_ID"="S_CAMP_CON"."ROW_ID"(+))
      38 - access("S_ORDER"."ENTLMNT_ID"="S_ENTLMNT"."ROW_ID"(+))
      40 - access("S_ORDER"."PROMO_ID"="S_SRC"."ROW_ID"(+))
      42 - access("S_CAMP_CON"."CAMP_LD_WAVE_ID"="S_CAMP_LD_WAVE"."ROW_ID"(+))
      44 - access("S_ORDER"."QUOTE_ID"="QUOTE"."ROW_ID"(+))
      46 - access("S_ORDER"."PR_POSTN_ID"="POSOWNERORG"."ROW_ID"(+))
      47 - filter("S_ORDER_ITEM"."ORDER_ID"="S_ORDER"."ROW_ID")
      50 - filter("S_ORDER_ITEM"."ROOT_ORDER_ITEM_ID" IS NOT NULL)
      51 - access("S_ORDER_ITEM"."ROW_ID"="S_ETL_I_IMG_25"."ROW_ID")
      53 - access("S_ORDER_ITEM"."VOL_DISCNT_ITEM_ID"="A"."ROW_ID"(+))
      55 - access("S_ORDER_ITEM"."VOL_DISCNT_ID"="S_VOL_DISCNT"."ROW_ID"(+))
      57 - access("S_ORDER_ITEM"."VOL_UPSELL_ITEM_ID"="B"."ROW_ID"(+))
      59 - access("S_ORDER_ITEM"."SHIP_ADDR_ID"="SHIPOITEM"."ROW_ID"(+))
      60 - filter("S_ORDER_ITEM"."ROW_ID"="OPRI"."PAR_ROW_ID"(+))
    PLAN_TABLE_OUTPUT
      62 - access("S_ORDER_ITEM"."SRC_INVLOC_ID"="S_INVLOC"."ROW_ID"(+))
      64 - access("S_ORDER_ITEM"."PROD_ID"="S_PROD_INT"."ROW_ID"(+))
      66 - access("S_ORDER_ITEM"."ORDER_ID"="S_ORDER_X"."PAR_ROW_ID"(+))
      68 - access("S_ORDER_ITEM"."CREATED_BY"="CRTD"."ROW_ID"(+))
      70 - access("CRTD"."PR_HELD_POSTN_ID"="POSCRTDORG"."ROW_ID"(+))
      72 - access("S_ORDER"."APPR_BY_EMP_ID"="APPRBYPOS"."ROW_ID"(+))
      74 - access("S_ORDER"."ACCNT_ID"="ACCNT"."ROW_ID"(+))
      76 - access("POSOWNERORG"."OU_ID"="OWNORG1"."ROW_ID"(+))
      78 - access("OWNORG1"."PAR_BU_ID"="OWNORG"."ROW_ID"(+))
      80 - access("S_ORDER_ITEM"."ROOT_ORDER_ITEM_ID"="ROOTOITEM"."ROW_ID")
      82 - access("S_ORDER_ITEM"."PAR_ORDER_ITEM_ID"="PAROITEM"."ROW_ID"(+))
      84 - access("PAROITEM"."PROD_ID"="PARPROD"."ROW_ID"(+))
      86 - access("ROOTOITEM"."PROD_ID"="ROOTPROD"."ROW_ID"(+))
      88 - access("S_ORDER"."BU_ID"="VISORG1"."ROW_ID"(+))
      90 - access("VISORG1"."PAR_BU_ID"="VISORG"."ROW_ID"(+))
    132 rows selected.Edited by: KODS on Dec 13, 2012 2:11 PM

    Output of : select * from table(dbms_xplan.display_cursor('4nn6jbvwf0b2k', null, 'iostats last'));
    PLAN_TABLE_OUTPUT
    SQL_ID  4nn6jbvwf0b2k, child number 0
             S_ORDER.APPR_BY_EMP_ID ,
             S_ORDER.CARRIER_CD ,
             S_ORDER.CURCY_CD ,
             S_ORDER.SHIP_ADDR_ID,
             S_ORDER.SHIP_METH_CD ,
             S_ORDER.TAX_EXEMPT_NUM ,
             S_ORDER.BU_IDID ,EASON ,
             S_ORDER.PRI_LST_ID ,
             S_ORDER.ENTLMNT_ID ENTITLEMENT_ID ,
             S_ORDER_ITEM.ROW_ID ,,
             S_ORDER_ITEM.PROD_ID,
             S_ORDER_ITEM.BASE_UNIT_PRI ,
    S_
    Plan hash value: 73463824
    | Id  | Operation                                                | Name              | E-Rows |
    |   1 |  NESTED LOOPS OUTER                                      |                   |   3170K|
    |   2 |   NESTED LOOPS OUTER                                     |                   |   3170K|
    |   3 |    NESTED LOOPS OUTER                                    |                   |   3170K|
    |   4 |     NESTED LOOPS OUTER                                   |                   |   3170K|
    |   5 |      NESTED LOOPS OUTER                                  |                   |   3170K|
    |   6 |       NESTED LOOPS                                       |                   |   3170K|
    |   7 |        NESTED LOOPS OUTER                                |                   |   3170K|
    |   8 |         NESTED LOOPS OUTER                               |                   |   3170K|
    |   9 |          NESTED LOOPS OUTER                              |                   |   3170K|
    |  10 |           NESTED LOOPS OUTER                             |                   |   3170K|
    |  11 |            NESTED LOOPS OUTER                            |                   |   3170K|
    |  12 |             NESTED LOOPS OUTER                           |                   |   3170K|
    |  13 |              NESTED LOOPS OUTER                          |                   |   3170K|
    |  14 |               NESTED LOOPS OUTER                         |                   |   3170K|
    |  15 |                NESTED LOOPS OUTER                        |                   |   3170K|
    |  16 |                 NESTED LOOPS OUTER                       |                   |   3170K|
    |  17 |                  NESTED LOOPS OUTER                      |                   |   3170K|
    |  18 |                   NESTED LOOPS OUTER                     |                   |   3170K|
    |  19 |                    NESTED LOOPS OUTER                    |                   |   3170K|
    |  20 |                     NESTED LOOPS OUTER                   |                   |   3170K|
    |  21 |                      NESTED LOOPS                        |                   |   3170K|
    |  22 |                       NESTED LOOPS OUTER                 |                   |   3108K|
    |  23 |                        NESTED LOOPS OUTER                |                   |   3108K|
    |  24 |                         NESTED LOOPS OUTER               |                   |   3108K|
    |  25 |                          NESTED LOOPS OUTER              |                   |   3108K|
    |  26 |                           NESTED LOOPS OUTER             |                   |   3108K|
    |  27 |                            NESTED LOOPS OUTER            |                   |   3108K|
    |  28 |                             NESTED LOOPS OUTER           |                   |   3108K|
    |  29 |                              NESTED LOOPS OUTER          |                   |   3108K|
    |  30 |                               TABLE ACCESS FULL          | S_ORDER           |   3108K|
    |  31 |                               TABLE ACCESS BY INDEX ROWID| S_ADDR_ORG        |      1 |
    |* 32 |                                INDEX UNIQUE SCAN         | S_ADDR_ORG_P1     |      1 |
    |  33 |                              TABLE ACCESS BY INDEX ROWID | S_ADDR_ORG        |      1 |
    |* 34 |                               INDEX UNIQUE SCAN          | S_ADDR_ORG_P1     |      1 |
    |  35 |                             TABLE ACCESS BY INDEX ROWID  | S_CAMP_CON        |      1 |
    |* 36 |                              INDEX UNIQUE SCAN           | S_CAMP_CON_P1     |      1 |
    |  37 |                            TABLE ACCESS BY INDEX ROWID   | S_ENTLMNT         |      1 |
    |* 38 |                             INDEX UNIQUE SCAN            | S_ENTLMNT_P1      |      1 |
    |  39 |                           TABLE ACCESS BY INDEX ROWID    | S_SRC             |      1 |
    |* 40 |                            INDEX UNIQUE SCAN             | S_SRC_P1          |      1 |
    |  41 |                          TABLE ACCESS BY INDEX ROWID     | S_CAMP_LD_WAVE    |      1 |
    |* 42 |                           INDEX UNIQUE SCAN              | S_CAMP_LD_WAVE_P1 |      1 |
    |  43 |                         TABLE ACCESS BY INDEX ROWID      | S_DOC_QUOTE       |      1 |
    |* 44 |                          INDEX UNIQUE SCAN               | S_DOC_QUOTE_P1    |      1 |
    |  45 |                        TABLE ACCESS BY INDEX ROWID       | S_POSTN           |      1 |
    |* 46 |                         INDEX UNIQUE SCAN                | S_POSTN_P1        |      1 |
    |* 47 |                       VIEW                               | V_ORDER_ITEM      |      1 |
    |  48 |                        NESTED LOOPS                      |                   |   3128K|
    |  49 |                         INDEX FAST FULL SCAN             | S_ETL_I_IMG_25_M2 |   3128K|
    |* 50 |                         TABLE ACCESS BY INDEX ROWID      | S_ORDER_ITEM      |      1 |
    |* 51 |                          INDEX UNIQUE SCAN               | S_ORDER_ITEM_P1   |      1 |
    |  52 |                      TABLE ACCESS BY INDEX ROWID         | S_VDISCNT_ITEM    |      1 |
    |* 53 |                       INDEX UNIQUE SCAN                  | S_VDISCNT_ITEM_P1 |      1 |
    |  54 |                     TABLE ACCESS BY INDEX ROWID          | S_VOL_DISCNT      |      1 |
    |* 55 |                      INDEX UNIQUE SCAN                   | S_VOL_DISCNT_P1   |      1 |
    |  56 |                    TABLE ACCESS BY INDEX ROWID           | S_VDISCNT_ITEM    |      1 |
    |* 57 |                     INDEX UNIQUE SCAN                    | S_VDISCNT_ITEM_P1 |      1 |
    |  58 |                   TABLE ACCESS BY INDEX ROWID            | S_ADDR_ORG        |      1 |
    |* 59 |                    INDEX UNIQUE SCAN                     | S_ADDR_ORG_P1     |      1 |
    |* 60 |                  TABLE ACCESS FULL                       | S_ORDER_ITM_PRI   |      1 |
    |  61 |                 TABLE ACCESS BY INDEX ROWID              | S_INVLOC          |      1 |
    |* 62 |                  INDEX UNIQUE SCAN                       | S_INVLOC_P1       |      1 |
    |  63 |                TABLE ACCESS BY INDEX ROWID               | S_PROD_INT        |      1 |
    |* 64 |                 INDEX UNIQUE SCAN                        | S_PROD_INT_P1     |      1 |
    |  65 |               TABLE ACCESS BY INDEX ROWID                | S_ORDER_X         |      1 |
    |* 66 |                INDEX RANGE SCAN                          | S_ORDER_X_U1      |      1 |
    |  67 |              TABLE ACCESS BY INDEX ROWID                 | S_CONTACT         |      1 |
    |* 68 |               INDEX UNIQUE SCAN                          | S_CONTACT_P1      |      1 |
    |  69 |             TABLE ACCESS BY INDEX ROWID                  | S_POSTN           |      1 |
    |* 70 |              INDEX UNIQUE SCAN                           | S_POSTN_P1        |      1 |
    |  71 |            TABLE ACCESS BY INDEX ROWID                   | S_CONTACT         |      1 |
    |* 72 |             INDEX UNIQUE SCAN                            | S_CONTACT_P1      |      1 |
    |  73 |           TABLE ACCESS BY INDEX ROWID                    | S_ORG_EXT         |      1 |
    |* 74 |            INDEX UNIQUE SCAN                             | S_ORG_EXT_P1      |      1 |
    |  75 |          TABLE ACCESS BY INDEX ROWID                     | S_ORG_EXT         |      1 |
    |* 76 |           INDEX UNIQUE SCAN                              | S_ORG_EXT_P1      |      1 |
    |  77 |         TABLE ACCESS BY INDEX ROWID                      | S_ORG_EXT         |      1 |
    |* 78 |          INDEX UNIQUE SCAN                               | S_ORG_EXT_P1      |      1 |
    |  79 |        TABLE ACCESS BY INDEX ROWID                       | S_ORDER_ITEM      |      1 |
    |* 80 |         INDEX UNIQUE SCAN                                | S_ORDER_ITEM_P1   |      1 |
    |  81 |       TABLE ACCESS BY INDEX ROWID                        | S_ORDER_ITEM      |      1 |
    |* 82 |        INDEX UNIQUE SCAN                                 | S_ORDER_ITEM_P1   |      1 |
    |  83 |      TABLE ACCESS BY INDEX ROWID                         | S_PROD_INT        |      1 |
    |* 84 |       INDEX UNIQUE SCAN                                  | S_PROD_INT_P1     |      1 |
    |  85 |     TABLE ACCESS BY INDEX ROWID                          | S_PROD_INT        |      1 |
    |* 86 |      INDEX UNIQUE SCAN                                   | S_PROD_INT_P1     |      1 |
    |  87 |    TABLE ACCESS BY INDEX ROWID                           | S_ORG_EXT         |      1 |
    |* 88 |     INDEX UNIQUE SCAN                                    | S_ORG_EXT_P1      |      1 |
    |  89 |   TABLE ACCESS BY INDEX ROWID                            | S_ORG_EXT         |      1 |
    |* 90 |    INDEX UNIQUE SCAN                                     | S_ORG_EXT_P1      |      1 |
    Predicate Information (identified by operation id):
      32 - access("S_ORDER"."SHIP_ADDR_ID"="SHIPO"."ROW_ID")
    PLAN_TABLE_OUTPUT
      34 - access("S_ORDER"."BL_ADDR_ID"="BILL"."ROW_ID")
      36 - access("S_ORDER"."CAMP_CON_ID"="S_CAMP_CON"."ROW_ID")
      38 - access("S_ORDER"."ENTLMNT_ID"="S_ENTLMNT"."ROW_ID")
      40 - access("S_ORDER"."PROMO_ID"="S_SRC"."ROW_ID")
      42 - access("S_CAMP_CON"."CAMP_LD_WAVE_ID"="S_CAMP_LD_WAVE"."ROW_ID")
      44 - access("S_ORDER"."QUOTE_ID"="QUOTE"."ROW_ID")
      46 - access("S_ORDER"."PR_POSTN_ID"="POSOWNERORG"."ROW_ID")
      47 - filter("S_ORDER_ITEM"."ORDER_ID"="S_ORDER"."ROW_ID")
      50 - filter("S_ORDER_ITEM"."ROOT_ORDER_ITEM_ID" IS NOT NULL)
      51 - access("S_ORDER_ITEM"."ROW_ID"="S_ETL_I_IMG_25"."ROW_ID")
      53 - access("S_ORDER_ITEM"."VOL_DISCNT_ITEM_ID"="A"."ROW_ID")
      55 - access("S_ORDER_ITEM"."VOL_DISCNT_ID"="S_VOL_DISCNT"."ROW_ID")
      57 - access("S_ORDER_ITEM"."VOL_UPSELL_ITEM_ID"="B"."ROW_ID")
      59 - access("S_ORDER_ITEM"."SHIP_ADDR_ID"="SHIPOITEM"."ROW_ID")
      60 - filter("S_ORDER_ITEM"."ROW_ID"="OPRI"."PAR_ROW_ID")
      62 - access("S_ORDER_ITEM"."SRC_INVLOC_ID"="S_INVLOC"."ROW_ID")
      64 - access("S_ORDER_ITEM"."PROD_ID"="S_PROD_INT"."ROW_ID")
      66 - access("S_ORDER_ITEM"."ORDER_ID"="S_ORDER_X"."PAR_ROW_ID")
      68 - access("S_ORDER_ITEM"."CREATED_BY"="CRTD"."ROW_ID")
      70 - access("CRTD"."PR_HELD_POSTN_ID"="POSCRTDORG"."ROW_ID")
      72 - access("S_ORDER"."APPR_BY_EMP_ID"="APPRBYPOS"."ROW_ID")
      74 - access("S_ORDER"."ACCNT_ID"="ACCNT"."ROW_ID")
      76 - access("POSOWNERORG"."OU_ID"="OWNORG1"."ROW_ID")
      78 - access("OWNORG1"."PAR_BU_ID"="OWNORG"."ROW_ID")
      80 - access("S_ORDER_ITEM"."ROOT_ORDER_ITEM_ID"="ROOTOITEM"."ROW_ID")
      82 - access("S_ORDER_ITEM"."PAR_ORDER_ITEM_ID"="PAROITEM"."ROW_ID")
      84 - access("PAROITEM"."PROD_ID"="PARPROD"."ROW_ID")
      86 - access("ROOTOITEM"."PROD_ID"="ROOTPROD"."ROW_ID")
      88 - access("S_ORDER"."BU_ID"="VISORG1"."ROW_ID")
      90 - access("VISORG1"."PAR_BU_ID"="VISORG"."ROW_ID")
    Note
       - Warning: basic plan statistics not available. These are only collected when:
           * hint 'gather_plan_statistics' is used for the statement or
           * parameter 'statistics_level' is set to 'ALL', at session or system level
    154 rows selected.

  • Buffer gets and logical reads

    Hello !
    Does the counter of event buffer gets include the logical reads ?
    Does the mertic buffer gets include the event of reading from undo buffer ?
    Thanks and regards,
    Pavel
    Edited by: Pavel on Jun 27, 2012 3:08 AM
    Edited by: Pavel on Jun 27, 2012 3:35 AM
    Edited by: Pavel on Jun 27, 2012 4:13 AM

    Hi,
    buffer gets = number of times a block was requested from buffer cache. A buffer get always request in a logical read. Depending on whether or not a copy of the block is available in the buffer cache, a logical read may or may not involve a physical read. So "buffer gets" and "logical reads" are basically synonyms and are often used interchangeably.
    Oracle doesn't have a special "undo buffer". Undo blocks are stored in rollback segments in UNDO tablespace, and are managed in the same way data blocks are (they're even protected by redo). If a consistent get requires reading from UNDO tablespace, then statistics counters will show that, i.e. there will be one more consistent get in your autotrace.
    For more information and some examples, see a thread at askTom:
    http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:549546900346542976
    Best regards,
    Nikolay

  • Logical Reads are very high when run as sproc and very less logical reads when run as a script

    Hello 
    Have a question, 
    when i execute a sproc. i get a very high logical reads count and when i run the same sproc converted into script it has very low logical reads what does it mean..

    I would like you to check query plan during ad-hoc run versus stored procedure execution. As other pointed out it could be due to parameter sniffing.
    Balmukund Lakhani
    Please mark solved if I've answered your question, vote for it as helpful to help other users find a solution quicker
    This posting is provided "AS IS" with no warranties, and confers no rights.
    My Blog |
    Team Blog | @Twitter
    | Facebook
    Author: SQL Server 2012 AlwaysOn -
    Paperback, Kindle

  • Execution plan change when querying count(*)

    Hi,
    Could any one please help me....
    Here are my queries
    1. select * from my_vew
    2. select count(*) from my_view
    Explain plan on the above queries are giving differnt plans. I would like to get the plan for count(*) as exactkly same as query no 1. Even I tried explain plan for the below query, which is also not giving the same plan..
    select count(*) from (select * from my_view);
    All I am trying to do here is to find the total run time without spending much time on passing the result to the client over a network (I beleive set autotrace traceonly option is also passing the result to the network.. only thing is that traceonly option wont display the results). count(*) query is chaning the plan in many ways such as index scan in place of full_table scan and etc.,
    Thanks in advance.
    Vasanth

    why you want select count(*) from <table>,cause count(*) did single call neednt arraysize to be big which in turn less
    LIO,when less LIO then high throughput which is not the case with select * from <table>,i dont know the internals of count(*)
    but there would be some mechanics behind this code which always return with less IO
    SQL> conn scott/tiger
    Connected.
    SQL> column plan_plus_exp format a100
    SQL> set linesize 1000
    SQL> desc t
    Name                                                                                                                  
    A                                                                                                                     
    OBJECT_NAME                                                                                                           
    SQL> select index_name from user_indexes where lower(table_name)='t'
      2  /
    no rows selected
    SQL> select count(*) from t
      2  /
      COUNT(*)
         23486
    SQL> set autotrace traceonly
    SQL> select * from t
      2  /
    23486 rows selected.
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=13 Card=23486 Bytes=681094)
       1    0   TABLE ACCESS (FULL) OF 'T' (Cost=13 Card=23486 Bytes=681094)
    Statistics
             23  recursive calls
              0  db block gets
           1678  consistent gets
              0  physical reads
              0  redo size
         923712  bytes sent via SQL*Net to client
          17714  bytes received via SQL*Net from client
           1567  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
          23486  rows processed
    SQL> select count(*) from t
      2  /
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=13 Card=1)
       1    0   SORT (AGGREGATE)
       2    1     TABLE ACCESS (FULL) OF 'T' (Cost=13 Card=23486)
    Statistics
              0  recursive calls
              0  db block gets
            118  consistent gets
              0  physical reads
              0  redo size
            381  bytes sent via SQL*Net to client
            499  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              1  rows processedyou need to compare boths query result consistent gets as well bytes sent via SQL*Net to client and bytes received via SQL*Net from client.
    What yours requirment to get alls record as well as maximum throughput,its not the way to do.Just a clue try to implement bulk collect in this case.
    Khurram

  • Query optimization - Query is taking long time even there is no table scan in execution plan

    Hi All,
    The below query execution is taking very long time even there are all required indexes present. 
    Also in execution plan there is no table scan. I did a lot of research but i am unable to find a solution. 
    Please help, this is required very urgently. Thanks in advance. :)
    WITH cte
    AS (
    SELECT Acc_ex1_3
    FROM Acc_ex1
    INNER JOIN Acc_ex5 ON (
    Acc_ex1.Acc_ex1_Id = Acc_ex5.Acc_ex5_Id
    AND Acc_ex1.OwnerID = Acc_ex5.OwnerID
    WHERE (
    cast(Acc_ex5.Acc_ex5_92 AS DATETIME) >= '12/31/2010 18:30:00'
    AND cast(Acc_ex5.Acc_ex5_92 AS DATETIME) < '01/31/2014 18:30:00'
    SELECT DISTINCT R.ReportsTo AS directReportingUserId
    ,UC.UserName AS EmpName
    ,UC.EmployeeCode AS EmpCode
    ,UEx1.Use_ex1_1 AS PortfolioCode
    SELECT TOP 1 TerritoryName
    FROM UserTerritoryLevelView
    WHERE displayOrder = 6
    AND UserId = R.ReportsTo
    ) AS BranchName
    ,GroupsNotContacted AS groupLastContact
    ,GroupCount AS groupTotal
    FROM ReportingMembers R
    INNER JOIN TeamMembers T ON (
    T.OwnerID = R.OwnerID
    AND T.MemberID = R.ReportsTo
    AND T.ReportsTo = 1
    INNER JOIN UserContact UC ON (
    UC.CompanyID = R.OwnerID
    AND UC.UserID = R.ReportsTo
    INNER JOIN Use_ex1 UEx1 ON (
    UEx1.OwnerId = R.OwnerID
    AND UEx1.Use_ex1_Id = R.ReportsTo
    INNER JOIN (
    SELECT Accounts.AssignedTo
    ,count(DISTINCT Acc_ex1_3) AS GroupCount
    FROM Accounts
    INNER JOIN Acc_ex1 ON (
    Accounts.AccountID = Acc_ex1.Acc_ex1_Id
    AND Acc_ex1.Acc_ex1_3 > '0'
    AND Accounts.OwnerID = 109
    GROUP BY Accounts.AssignedTo
    ) TotalGroups ON (TotalGroups.AssignedTo = R.ReportsTo)
    INNER JOIN (
    SELECT Accounts.AssignedTo
    ,count(DISTINCT Acc_ex1_3) AS GroupsNotContacted
    FROM Accounts
    INNER JOIN Acc_ex1 ON (
    Accounts.AccountID = Acc_ex1.Acc_ex1_Id
    AND Acc_ex1.OwnerID = Accounts.OwnerID
    AND Acc_ex1.Acc_ex1_3 > '0'
    INNER JOIN Acc_ex5 ON (
    Accounts.AccountID = Acc_ex5.Acc_ex5_Id
    AND Acc_ex5.OwnerID = Accounts.OwnerID
    WHERE Accounts.OwnerID = 109
    AND Acc_ex1.Acc_ex1_3 NOT IN (
    SELECT Acc_ex1_3
    FROM cte
    GROUP BY Accounts.AssignedTo
    ) TotalGroupsNotContacted ON (TotalGroupsNotContacted.AssignedTo = R.ReportsTo)
    WHERE R.OwnerID = 109
    Please mark it as an answer/helpful if you find it as useful. Thanks, Satya Prakash Jugran

    Hi All,
    Thanks for the replies.
    I have optimized that query to make it run in few seconds.
    Here is my final query.
    select ReportsTo as directReportingUserId, 
    UserName AS EmpName, 
    EmployeeCode AS EmpCode,
    Use_ex1_1 AS PortfolioCode,
    BranchName,
    GroupInfo.groupTotal,
    GroupInfo.groupLastContact,
    case when exists
    (select 1 from ReportingMembers RM
    where RM.ReportsTo =  UserInfo.ReportsTo
    and RM.MemberID <> UserInfo.ReportsTo
    ) then 0  else UserInfo.ReportsTo end as memberid1,
    (select code from Regions where ownerid=109 and  name=UserInfo.BranchName) as BranchCode,
    ROW_NUMBER() OVER (ORDER BY directReportingUserId) AS ROWNUMBER
    FROM 
    (select distinct R.ReportsTo, UC.UserName, UC.EmployeeCode,UEx1.Use_ex1_1,
    (select top 1 TerritoryName 
    from UserTerritoryLevelView
    where displayOrder = 6
    and UserId = R.ReportsTo) as BranchName,
    Case when R.ReportsTo = Accounts.AssignedTo then Accounts.AssignedTo else 0 end as memberid1
    from ReportingMembers R
    INNER JOIN TeamMembers T ON (T.OwnerID = R.OwnerID AND T.MemberID = R.ReportsTo AND T.ReportsTo = 1)
    inner join UserContact UC on (UC.CompanyID = R.OwnerID and UC.UserID = R.ReportsTo )
    inner join Use_ex1 UEx1 on (UEx1.OwnerId = R.OwnerID and UEx1.Use_ex1_Id = R.ReportsTo)
    inner join Accounts on (Accounts.OwnerID = 109 and Accounts.AssignedTo = R.ReportsTo)
    union
    select distinct R.ReportsTo, UC.UserName, UC.EmployeeCode,UEx1.Use_ex1_1,
    (select top 1 TerritoryName 
    from UserTerritoryLevelView
    where displayOrder = 6
    and UserId = R.ReportsTo) as BranchName,
    Case when R.ReportsTo = Accounts.AssignedTo then Accounts.AssignedTo else 0 end as memberid1
    from ReportingMembers R
    --INNER JOIN TeamMembers T ON (T.OwnerID = R.OwnerID AND T.MemberID = R.ReportsTo)
    inner join UserContact UC on (UC.CompanyID = R.OwnerID and UC.UserID = R.ReportsTo)
    inner join Use_ex1 UEx1 on (UEx1.OwnerId = R.OwnerID and UEx1.Use_ex1_Id = R.ReportsTo)
    inner join Accounts on (Accounts.OwnerID = 109 and Accounts.AssignedTo = R.ReportsTo)
    where R.MemberID = 1
    ) UserInfo
    inner join 
    select directReportingUserId, sum(Groups) as groupTotal, SUM(GroupsNotContacted) as groupLastContact
    from
    select distinct R.ReportsTo as directReportingUserId, Acc_ex1_3 as GroupName, 1 as Groups,
    case when Acc_ex5.Acc_ex5_92 between GETDATE()-365*10 and GETDATE() then 1 else 0 end as GroupsNotContacted
    FROM ReportingMembers R
    INNER JOIN TeamMembers T 
    ON (T.OwnerID = R.OwnerID AND T.MemberID = R.ReportsTo AND T.ReportsTo = 1)
    inner join Accounts on (Accounts.OwnerID = 109 and Accounts.AssignedTo = R.ReportsTo)
    inner join Acc_ex1 on (Acc_ex1.OwnerID = 109 and Acc_ex1.Acc_ex1_Id = Accounts.AccountID and Acc_ex1.Acc_ex1_3 > '0')
    inner join Acc_ex5 on (Acc_ex5.OwnerID = 109 and Acc_ex5.Acc_ex5_Id = Accounts.AccountID )
    --where TerritoryID in ( select ChildRegionID  RegionID from RegionWithSubRegions where OwnerID =109 and RegionID = 729)
    union 
    select distinct R.ReportsTo as directReportingUserId, Acc_ex1_3 as GroupName, 1 as Groups,
    case when Acc_ex5.Acc_ex5_92 between GETDATE()-365*10 and GETDATE() then 1 else 0 end as GroupsNotContacted
    FROM ReportingMembers R
    INNER JOIN TeamMembers T 
    ON (T.OwnerID = R.OwnerID AND T.MemberID = R.ReportsTo)
    inner join Accounts on (Accounts.OwnerID = 109 and Accounts.AssignedTo = R.ReportsTo)
    inner join Acc_ex1 on (Acc_ex1.OwnerID = 109 and Acc_ex1.Acc_ex1_Id = Accounts.AccountID and Acc_ex1.Acc_ex1_3 > '0')
    inner join Acc_ex5 on (Acc_ex5.OwnerID = 109 and Acc_ex5.Acc_ex5_Id = Accounts.AccountID )
    --where TerritoryID in ( select ChildRegionID  RegionID from RegionWithSubRegions where OwnerID =109 and RegionID = 729)
    where R.MemberID = 1
    ) GroupWiseInfo
    group by directReportingUserId
    ) GroupInfo
    on UserInfo.ReportsTo = GroupInfo.directReportingUserId
    Please mark it as an answer/helpful if you find it as useful. Thanks, Satya Prakash Jugran

Maybe you are looking for

  • Problem with RFC and a Z Table

    hi; i´ve created a Z table as a transparent table.... now in a function module a need to save data in that table, i do the next:           zfactura-vbeln_vf  = i_factura.           zfactura-posicion = i_posicion.           zfactura-fecha_em = i_fecha

  • Unable to log-in in OIM11g during upgrade from 9.1.0.2

    Team, We are upgrading OIM from 9.1.0.2 to 11g following below guide. http://docs.oracle.com/cd/E21764_01/upgrade.1111/e10129/upgrade_oim.htm Below mentioned steps have been completed successfully. Task 1: Identify and Prepare Oracle Database for Ora

  • Transfering  aperture library via vault to new comp

    I apologize in advance if my question already have been answered in another thread. But I couldn't find any threads matching my problems. I recently bought the new iMac after my old 24" could not handle the pressure anymore. I wanted to move my apert

  • XL-reporter Error

    Hallow expert .. I have problems installing xl reporter there who want to help say to complete my task, when I run the Xl-reporter no warning: runtime error "429" ActiveX component cannot create object. what should I do? thanks

  • How can i obtain the audio cards list of my pc in labview ?

    I have many audio cards installed on my pc. I want to show this cards in an enum of LabVIEW. How must i do ?