SQL Query is very slow

Hello ,
I have a table like employee having more than 80 Lakhs records .
In the table there is a country column (country_name) having 234 distinct countries .
I have created index on Country_name column to make it fast .
I have created a view (employee_country) which is having distinct countries . The view is populating the country_name from employee table .
So , in the view (employee_country) have 234 distinct countries .
Now if I run select count(*) from employee_country ; then the query is taking ( 320.391 seconds ) time to show result ..
I am using one query which is taking the country_name from this view and comparing to another table with the country names .
like for example :
select ec.country_name from employee_country ec where ec.country_name not in (select cdf.country_name from country_dnb_full cdf)
I am using this query in APEX page to get the country name . But this query is very samll and taking 350.725 seconds to show the result . Therefore the APEX page when we run is showing time out error because the query is taking too much time .
I don't know why this problem is ?? I already created a index on country_name column to speed up the result . But still its not happening .
Please some one guide me where the problem is .??
Thanks
Prashant Dwivedi

Hi Prashant
First thing the view does not store any data. Its just a definition and the select query gets excuted on the original table whenever the view is referred.
Probabaly you can check for Materialized View.
Alternatively you can have a Look Up table if you think the values for the country_name is constant.
Regards
Arun

Similar Messages

  • SQL Query Report Very slow

    Hi I have a sql query report that is taking very long to render.The query on sql developer comes back in less than a second.Any ideas on what could be wrong?

    Hi
    When posting code on the forum, put {noformat}{noformat} (with the curly brackets and the word code in lowercase) above and below your code like this...
    {noformat}{noformat}
    SELECT *
    FROM emp
    {noformat}{noformat}
    It will then appear like this, preserving formatting...SELECT *
    FROM emp
    Next, how many rows are returned in total, it may be that you have SQL Developer set up to fetch only the first x number of rows?
    Why have you put a CHOOSE hint in there?
    Is it a classic report or an interactive report?
    It looks like you're going over a database link, you really need to provide an explain plan (formatted as I have detailed above), a DRIVING_SITE hint may help you but it's impossible to know without seeing the plan...
    Cheers
    Ben                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Sql Query taking very long time to complete

    Hi All,
    DB:oracle 9i R2
    OS:sun solaris 8
    Below is the Sql Query taking very long time to complete
    Could any one help me out regarding this.
    SELECT MAX (md1.ID) ID, md1.request_id, md1.jlpp_transaction_id,
    md1.transaction_version
    FROM transaction_data_arc md1
    WHERE md1.transaction_name = :b2
    AND md1.transaction_type = 'REQUEST'
    AND md1.message_type_code = :b1
    AND NOT EXISTS (
    SELECT NULL
    FROM transaction_data_arc tdar2
    WHERE tdar2.request_id = md1.request_id
    AND tdar2.jlpp_transaction_id != md1.jlpp_transaction_id
    AND tdar2.ID > md1.ID)
    GROUP BY md1.request_id,
    md1.jlpp_transaction_id,
    md1.transaction_version
    Any alternate query to get the same results?
    kindly let me know if any one knows.
    regards,
    kk.
    Edited by: kk001 on Apr 27, 2011 11:23 AM

    Dear
    /* Formatted on 2011/04/27 08:32 (Formatter Plus v4.8.8) */
    SELECT   MAX (md1.ID) ID, md1.request_id, md1.jlpp_transaction_id,
             md1.transaction_version
        FROM transaction_data_arc md1
       WHERE md1.transaction_name = :b2
         AND md1.transaction_type = 'REQUEST'
         AND md1.message_type_code = :b1
         AND NOT EXISTS (
                SELECT NULL
                  FROM transaction_data_arc tdar2
                 WHERE tdar2.request_id = md1.request_id
                   AND tdar2.jlpp_transaction_id != md1.jlpp_transaction_id
                   AND tdar2.ID > md1.ID)
    GROUP BY md1.request_id
            ,md1.jlpp_transaction_id
            ,md1.transaction_versionCould you please post here :
    (a) the available indexes on transaction_data_arc table
    (b) the description of transaction_data_arc table
    (c) and the formatted explain plan you will get after executing the query and issuing:
    select * from table (dbms_xplan.display_cursor);Hope this helps
    Mohamed Houri

  • VO Query runs very slow in jdev, quickly in Toad/SQL Plus

    Hi,
    I am trying to create a search application using JSF with ADF BC. I have a VO based on a SQL query, which joins two tables. The search criteria is referenced using bind parameters in the VO.
    In Toad, SQL Plus, and SQL Developer, I can run my VO query and the results return quickly, within a couple of seconds. An Explain Plan indicates that all indexes are being correctly used. However, when I try to run my search form (exact same query) in jdev, it executes extremely slowly - almost 5 minutes before a result set is returned. My VO query is below.
    select oea.order_yr,
    oea.order_type,
    oea.order_key,
    oea.max_rev,
    oeo.profit_center_id,
    oeo.contract_total_price,
    oeo.complexity
    from oe_admin oea,
    oe_order oeo
    where oea.admin_id = oeo.admin_id
    and oeo.profit_center_id = :ProfitCenter
    and oea.order_yr = nvl(:OYear, oea.order_yr)
    and oea.order_type = nvl(:OType, oea.order_type)
    I've been messing with this for several days and I'm out of ideas. Does anyone have any suggestions?

    The question is not whether the query uses a viewLink but rather do you have any other views that are linked to this view - if you do have such views you might want to check the setting for whether children are retrieved as well.
    Also run ADF BC in debug mode to see the exact query that is being sent to the server and check out the explain plan for that one.

  • Challenging Query working very slow

    Hi Guys
    my query is working very slow .. i think i am using old functions to fetch data .. is anybody can recommand changes into it to make it faster
    SELECT  a.Student_Updated,
            a.Course_Updated,
            b.Notes_Updated,
            a.School_ID,
            a.School_Code,
            a.School_Name,
            a.Course_Code,
            a.Course_Name,
            ass.ass_type  Assessment_Type,
            ass.ass_status Assessment_Status,
            ass.ass_work_due_date  Assessment_Date,
            ass.ass_result_achieved  Assessment_result,
            a.Last_Name,
            a.First_Name,
            a.Initials,
            a.Stud_ID,
            a.User_ID,
            a.Email,
            b.Code1,
            b.Code2,
            b.Code3,
            b.Code4,
            b.Code5,
            b.Code6,
            b.Code7,
            b.Code8,
            b.Code9,
            b.Code10,
            b.Code11,
            b.Code12,
            b.Code13,
            b.Code14,
            b.Code15,
            b.Code16,
            b.Code17,
            b.Code18,
            b.Code19,
            b.Code20,
            b.Code21,
            b.Code22,
            b.Code23,
            b.Code24,
            a.Cert_Status,
            a.Class_Status,
            b.Notes1,
            b.Notes2,
            b.Notes3,
            b.Notes4
    FROM  
        (SELECT s.s_ref                            Stud_ID,
         s.s_date_changed                    Student_Updated,
         max(sba.sba_date_changed)                Course_Updated,
         cc.cc_user_value_1                    School_ID,
         lv.lv_high_value                    School_Code,
         lv.lv_meaning                        School_Name,
         sba.sba_sb_ref                        Course_Code,
         sb.sb_name                          Course_Name,
         s.s_surname                        Last_Name,
         s.s_forename_1                        First_Name,
         substr(s.s_forename_2, 1, 1)                 Initials,
         s.s_vehicle_reg_no                    User_ID,
         decode(s.s_e_mail_address,
                 null, decode(s.s_vehicle_reg_no,
                            null, null, s.s_vehicle_reg_no||'@abdn.ac.uk'),
                s.s_e_mail_address||'@aberdeen.ac.uk')    Email,
         sba.sba_significance                    Cert_Status,
         sba.sba_status                        Class_Status
        FROM students s,
             study_block_associations sba,
             study_blocks sb,
             cost_centres cc,
             calendar_periods cp,
             local_values lv
        WHERE s.s_ref = sba.sba_s_ref
         AND sba.sba_sb_ref = sb.sb_ref
         AND sb.sb_cc_ref = cc.cc_ref
         AND cc.cc_user_value_1 = lv.lv_value(+)
         AND lv.lv_domain = 'CC USER VALUE 1'
         --    AND    nvl(s.s_disabilities, '99') not in ('0', '0T', '00', '97', '98', '99')
         AND length(sba.sba_sb_ref) = '6'
         AND instr('L|W', sba.sba_status) > 0
         AND sba.sba_type = 'E'
         AND sba.sba_calp_period_code = cp.calp_period_code
         AND calp_cal_ref = 'RYEAR'
         AND trunc(sysdate) BETWEEN calp_start_date AND calp_end_date
        GROUP BY
            s.s_ref,
            s.s_date_changed,
            sba.sba_sb_ref,
            sb.sb_name,
            cc.cc_user_value_1,
            lv.lv_high_value,
            lv.lv_meaning,
            s.s_surname,
            s.s_forename_1,
            substr(s.s_forename_2, 1, 1),
            s.s_disabilities,
            s.s_vehicle_reg_no,
            decode(    s.s_e_mail_address,
                null,    decode(    s.s_vehicle_reg_no,
                        null,    null,
                            s.s_vehicle_reg_no||'@abdn.ac.uk'),
                    s.s_e_mail_address||'@aberdeen.ac.uk'),
            sba.sba_significance,
            sba.sba_status
        ) a,
        (SELECT    sle.sle_s_ref                        Stud_ID,
         max(sle.sle_date_created)                Notes_Updated,
         sum(case when sle.sle_le_ref = '01' then 1 else 0 end)    Code1,
         sum(case when sle.sle_le_ref = '02' then 1 else 0 end)    Code2,
         sum(case when sle.sle_le_ref = '03' then 1 else 0 end)    Code3,
         sum(case when sle.sle_le_ref = '04' then 1 else 0 end)    Code4,
         sum(case when sle.sle_le_ref = '05' then 1 else 0 end)    Code5,
         sum(case when sle.sle_le_ref = '06' then 1 else 0 end)    Code6,
         sum(case when sle.sle_le_ref = '07' then 1 else 0 end)    Code7,
         sum(case when sle.sle_le_ref = '08' then 1 else 0 end)    Code8,
         sum(case when sle.sle_le_ref = '09' then 1 else 0 end)    Code9,
         sum(case when sle.sle_le_ref = '10' then 1 else 0 end)    Code10,
         sum(case when sle.sle_le_ref = '11' then 1 else 0 end)    Code11,
         sum(case when sle.sle_le_ref = '12' then 1 else 0 end)    Code12,
         sum(case when sle.sle_le_ref = '13' then 1 else 0 end)    Code13,
         sum(case when sle.sle_le_ref = '14' then 1 else 0 end)    Code14,
         sum(case when sle.sle_le_ref = '15' then 1 else 0 end)    Code15,
         sum(case when sle.sle_le_ref = '16' then 1 else 0 end)    Code16,
         sum(case when sle.sle_le_ref = '17' then 1 else 0 end)    Code17,
         sum(case when sle.sle_le_ref = '18' then 1 else 0 end)    Code18,
         sum(case when sle.sle_le_ref = '19' then 1 else 0 end)    Code19,
         sum(case when sle.sle_le_ref = '20' then 1 else 0 end)    Code20,
         sum(case when sle.sle_le_ref = '21' then 1 else 0 end)    Code21,
         sum(case when sle.sle_le_ref = '22' then 1 else 0 end)    Code22,
         sum(case when sle.sle_le_ref = '23' then 1 else 0 end)    Code23,
         sum(case when sle.sle_le_ref = '24' then 1 else 0 end)    Code24,
         sle4.Notes1,
         sle4.Notes2,
         sle4.Notes3,
         sle4.Notes4
        FROM abdn_student_le_provisions sle,
            (SELECT    sle3.sle_s_ref,
                    max(case when sle3.ord = 1 then sle3.sle_description end) Notes1,
                    max(case when sle3.ord = 2 then sle3.sle_description end) Notes2,
                    max(case when sle3.ord = 3 then sle3.sle_description end) Notes3,
                    max(case when sle3.ord = 4 then sle3.sle_description end) Notes4
              FROM (SELECT    row_number() over (partition by sle2.sle_s_ref order by sle2.sle_s_ref) as ord,
                            sle2.sle_s_ref,
                            sle2.sle_description
                    FROM abdn_student_le_provisions sle2
                    WHERE sle2.sle_description is not null
                    ) sle3
             GROUP BY
                sle3.sle_s_ref
            ) sle4
        WHERE    sle.sle_s_ref = sle4.sle_s_ref(+)
        GROUP BY
            sle.sle_s_ref,
            sle4.Notes1,
            sle4.Notes2,
            sle4.Notes3,
            sle4.Notes4
        ) b,
        assessments ass
    WHERE a.Stud_ID = b.Stud_ID
    AND a.Stud_ID = ass.ass_s_ref(+)
    AND a.Course_Code = ass.ass_sb_ref(+);

    Thread: HOW TO: Post a SQL statement tuning request - template posting
    HOW TO: Post a SQL statement tuning request - template posting

  • Oracle query running very slow

    Hi,
    We've MS-Access application which was pointing to UDB. Now we migrated it to point Oracle DB 9.2. After migration some of the query is running very slow.
    These queries used to take less than 30 seconds in UDB now taking more than 5 Minutes in Oracle.
    some more obeservation :
    (1) Some of the queries using "HAVING" clause without any aggregate function. When I moved this condition to "WHERE" clause, performance improved a lot.
    But problem is that I can't suggest this solution to "USERS". They are creating query using "query wizard" in MS-Access and they started creating noise on this.
    (2) I tested same MDB in two different PCs and same query is returning records in 4 seconds in one system, is taking more than 10 minutes in other system.
    Since I'm new to MS-Access, I don't know what other information I need to provide here.
    Please help me out.

    ms wrote:
    Hi All
    I am using Oracle 11g . My table contains 10-12 lac rows.Do not use the word lac: it is common in the Indian sub-continent but not known much outside of
    there because it is not standard English.
    >
    1) what is the difference between a index on one column and an index of number of columns ( i.e composite index). The obvious answer of one contains only one column and the other contains more than one.
    2) For what columns in a where clause should index be created ( single columns index or composite index ).Depends
    3) Also can u suggest how to improve the perfomane of thsi query?Please read: SQL and PL/SQL FAQ
    which tells you how to ask a performance related question

  • MS-Access query running very slow

    Hi,
    We've MS-Access application which was pointing to UDB. Now we migrated it to point Oracle DB 9.2. After migration some of the query is running very slow.
    These queries used to take less than 30 seconds in UDB now taking more than 5 Minutes in Oracle.
    some more obeservation :
    (1) Some of the queries using "HAVING" clause without any aggregate function. When I moved this condition to "WHERE" clause, performance improved a lot.
    But problem is that I can't suggest this solution to "USERS". They are creating query using "query wizard" in MS-Access and they started creating noise on this.
    (2) I tested same MDB in two different PCs and same query is returning records in 4 seconds in one system, is taking more than 10 minutes in other system.
    Since I'm new to MS-Access, I don't know what other information I need to provide here.
    Please help me out.

    I have seen the problem like this,too
    can i have you

  • Sql is running very slow

    hello everyone
    here is my procedure
    in procedure select statement is running very slow it takes 20min
    DECLARE
    y10_pad_sd_1 number;
    y10_sad_sd_1 number;
    y10_sad_oe_1 number;
    y10_she18_avg_1 number;
    y10_she_avg_1 number;
    y10_o_pad_sd_1 number;
    y10_e_pad_sd_1 number;
    y10_o_sad_sd_1 number;
    y10_e_sad_sd_1 number;
    y15_pad_sd_1 number;
    y15_sad_sd_1 number;
    y15_sad_oe_1 number;
    y15_she18_avg_1 number;
    y15_she_avg_1 number;
    y15_o_pad_sd_1 number;
    y15_e_pad_sd_1 number;
    y15_o_sad_sd_1 number;
    y15_e_sad_sd_1 number;
    y20_pad_sd_1 number;
    y20_sad_sd_1 number;
    y20_sad_oe_1 number;
    y20_she18_avg_1 number;
    y20_she_avg_1 number;
    y20_o_pad_sd_1 number;
    y20_e_pad_sd_1 number;
    y20_o_sad_sd_1 number;
    y20_e_sad_sd_1 number;
    CURSOR c_pn IS
    SELECT
    pn_id pn_id
    ,pn_dm pn_dm
    ,arch_id arch_id
    ,o_ink o_ink
    ,o_color o_color
    ,e_ink e_ink
    ,e_color e_color
    FROM pn_list_iqp_95cl;
    type c7 is table of c_pn%rowtype;
    c8 c7;
    BEGIN
    open c_pn;
    fetch c_pn bulk collect into c8;
    close c_pn;
    for i in 1..c8.last loop
    SELECT /*+ use_hash(pmo pme) */
    LEAST(MAX ( pmo.y10_pad_sd ), MAX ( pme.y10_pad_sd ))
    ,LEAST(MAX ( pmo.y10_sad_sd ), MAX ( pme.y10_sad_sd ))
    ,LEAST(MAX ( pmo.y10_sad_oe ), MAX ( pme.y10_sad_oe ))
    ,LEAST(MAX ( pmo.y10_she18_avg), MAX ( pme.y10_she18_avg ))
    ,LEAST(MAX ( pmo.y10_she_avg ), MAX ( pme.y10_she_avg ))
    ,LEAST(MAX ( pmo.y10_o_pad_sd ), MAX ( pme.y10_o_pad_sd ))
    ,LEAST(MAX ( pmo.y10_e_pad_sd ), MAX ( pme.y10_e_pad_sd ))
    ,LEAST(MAX ( pmo.y10_o_sad_sd ), MAX ( pme.y10_o_sad_sd ))
    ,LEAST(MAX ( pmo.y10_e_sad_sd ), MAX ( pme.y10_e_sad_sd ))
    ,LEAST(MAX ( pmo.y15_pad_sd ), MAX ( pme.y15_pad_sd ))
    ,LEAST(MAX ( pmo.y15_sad_sd ), MAX ( pme.y15_sad_sd ))
    ,LEAST(MAX ( pmo.y15_sad_oe ), MAX ( pme.y15_sad_oe ))
    ,LEAST(MAX ( pmo.y15_she18_avg), MAX ( pme.y15_she18_avg ))
    ,LEAST(MAX ( pmo.y15_she_avg ), MAX ( pme.y15_she_avg ))
    ,LEAST(MAX ( pmo.y15_o_pad_sd ), MAX ( pme.y15_o_pad_sd ))
    ,LEAST(MAX ( pmo.y15_e_pad_sd ), MAX ( pme.y15_e_pad_sd ))
    ,LEAST(MAX ( pmo.y15_o_sad_sd ), MAX ( pme.y15_o_sad_sd ))
    ,LEAST(MAX ( pmo.y15_e_sad_sd ), MAX ( pme.y15_e_sad_sd ))
    ,LEAST(MAX ( pmo.y20_pad_sd ), MAX ( pme.y20_pad_sd ))
    ,LEAST(MAX ( pmo.y20_sad_sd ), MAX ( pme.y20_sad_sd ))
    ,LEAST(MAX ( pmo.y20_sad_oe ), MAX ( pme.y20_sad_oe ))
    ,LEAST(MAX ( pmo.y20_she18_avg), MAX ( pme.y20_she18_avg ))
    ,LEAST(MAX ( pmo.y20_she_avg ), MAX ( pme.y20_she_avg ))
    ,LEAST(MAX ( pmo.y20_o_pad_sd ), MAX ( pme.y20_o_pad_sd ))
    ,LEAST(MAX ( pmo.y20_e_pad_sd ), MAX ( pme.y20_e_pad_sd ))
    ,LEAST(MAX ( pmo.y20_o_sad_sd ), MAX ( pme.y20_o_sad_sd ))
    ,LEAST(MAX ( pmo.y20_e_sad_sd ), MAX ( pme.y20_e_sad_sd ))
    INTO
    y10_pad_sd_1
    ,y10_sad_sd_1
    ,y10_sad_oe_1
    ,y10_she18_avg_1
    ,y10_she_avg_1
    ,y10_o_pad_sd_1
    ,y10_e_pad_sd_1
    ,y10_o_sad_sd_1
    ,y10_e_sad_sd_1
    ,y15_pad_sd_1
    ,y15_sad_sd_1
    ,y15_sad_oe_1
    ,y15_she18_avg_1
    ,y15_she_avg_1
    ,y15_o_pad_sd_1
    ,y15_e_pad_sd_1
    ,y15_o_sad_sd_1
    ,y15_e_sad_sd_1
    ,y20_pad_sd_1
    ,y20_sad_sd_1
    ,y20_sad_oe_1
    ,y20_she18_avg_1
    ,y20_she_avg_1
    ,y20_o_pad_sd_1
    ,y20_e_pad_sd_1
    ,y20_o_sad_sd_1
    ,y20_e_sad_sd_1
    FROM pm_list_iqp_95cl pmo ,pm_list_iqp_95cl pme
    WHERE pmo.pn_id = pme.pn_id
    AND pme.pn_id = c8(i).pn_id
    AND pmo.slot_cd = 'O'
    AND pme.slot_cd = 'E';
    END LOOP;
    END;

    EXPLAIN PLAN FOR THIS QUERY
    cached plan :cost all rows(cost:4)
    step name step cost rows
    select statement 6 4
    sort(aggregate) 5 1
    merge join(cartesian) 4 4 1
    tellatel.pm_list_iqp_95cl table access(full) 1 2 1
    buffer(sort) 3 2 1
    tellatel.pm_list_iqp_95cl_table access(full) 2 2 1

  • Query runs very slow and sometime freezes

    Hi Experts,
    I have just installed SAP GUI 710 but when i open a query in analyzer it runs very slow and  if the variables are set for more than 6 months it just sits there and finally times out. It takes at least 5 minutes to open the query if it opens at all. Can you please advise me on how to resolve this issue??
    Thanks, point will be awarded.

    Worth running RSRT .
    Ravi Thothadri

  • SQL apply is very slow on Logical Standby..!!

    Hello all,
    We are having Data Guard setup in our environment where we are having Primary, Physical Standby as well as logical standby databases..
    DB Version : 10.2.0.1 in all databases (Pri, Phy and Logical)
    OS : RHEL4
    Only Oracle is running on this Box..
    Since last month we are facing problems in Logical Standby database where it seems SQL apply has become very slow..
    Archive log files are successfully transferring from Primary but since SQL apply has become slow logical standby is lagging behind primary by two days..
    How do i speed up this SQL apply..?? Any ideas and suggestions are most welcome..
    I checked TOP command to find out which oracle processes are consuming maximum CPU and i have found ora_p000_oracle, ora_p001_oracle, ora_p002_oracle, ora_p003_oracle, ora_p004_oracle, ora_p005_oracle, etc processes are consuming highest CPU and Load Average has always been above 1..
    Any help would be greatly appreciated..
    Thanks - HP

    Hello;
    These Oracle notes might help :
    Slow Performance In Logical Standby Database Due To Lots Of Activity On Sys.Aud$ [ID 862173.1]
    Oracle10g Data Guard SQL Apply Troubleshooting [ID 312434.1]
    Developer and DBA Tips to Optimize SQL Apply [ID 603361.1]
    Best Regards
    mseberg

  • SQL Developer is very slow...

    I'm having performance issues with Oracle SQL Developer. I tried both and 1.5.4 and 2.1.0 (installed in Windows XP Professional) and both work very slow. When I connect to the same database in Apex or just the webconsole, performance is OK, so I think it's SQL Developer that's slow, not the database.
    The problem is that the "Connected To Database..." screen with the "knightrider-bar" appears for some seconds for almost every action I want to perform (retrieving all views, showing constraints, triggers, etc...). Always the waiting screen appears for 3 - 5 seconds, which is very annoying.
    Anybody knows what could be the problem? Working through the SQL Console in APEX is much more performant at this moment, but SQL Developer is more handy (if it would work faster).

    thefurryone wrote:
    Tom,
    As well as the ide/bin folder, there is a sqldeveloper/bin folder, which has a sqldeveloper.exe as well as the one in the root folder.
    Just as another thought - where is SQL Developer installed? Is it local on your PC or on a network drive? Especially when using the version with the included JDK, running off a network drive can be much slower.
    theFurryOneOK, found it now. I opened SQLDeveloper there and the console didn't show any messages. When I connect to the database I got this message in the console:
    Finished parsing = 15+
    UsersCache.fillIn() time = 0  ret==null?: true+
    I don't run SQLDeveloper from a network drive, it's installed locally on my C:\ drive. The database however is on a server, but I have a gigabit connection to it and applications don't have performance issues. So I suppose it's actually SQLDeveloper that's slow. Are there any tools in SQLDeveloper that could cause the bad performance, and that I could switch off?

  • Some body please help about the Inventory FIFO (FIRST IN FISRT OUT ) query is very slow

    I have table ''tran_stock''  to store a transaction (IN-OUT) of the stock. 
    The problem is when the  transaction rows are more than 50000 the query to get the balance
    stock (Total 'IN' - Total'Out' by FIFO) is very slow . Somebody please suggest me to do this.
    This is my query
    ;WITH OrderedIn as (
        select *,ROW_NUMBER() OVER (PARTITION BY Stock_ID ORDER BY TranDate) as rn
        from Tran_Stock
        where TxnType = 'IN'  
    ), RunningTotals as (
        select  Stock_ID ,Qty,Price,Qty as Total,Cast(0 as decimal(10,2)) as PrevTotal ,  trandate , rn  from OrderedIn where rn = 1
        union all
        select  rt.Stock_ID,oi.Qty,oi.Price,Cast(rt.Total + oi.Qty as decimal(10,2)),Cast(rt.Total as decimal(10,2)) , oi.TranDate ,oi.rn 
        from
            RunningTotals rt
                inner join
            OrderedIn oi
                on
                    rt.Stock_ID = oi.Stock_ID and
                    rt.rn = oi.rn - 1
    , TotalOut as (
    select Stock_ID ,SUM(Qty) as Qty from Tran_Stock where TxnType='OUT'   group by Stock_ID
    ) ,  GrandTotal as 
    select
         rt.Stock_ID , rt.QTY AS original ,SUM(CASE WHEN PrevTotal > isNULL(out.Qty, 0) THEN rt.Qty ELSE rt.Total - isNULL(out.Qty, 0) END) AS QTY , Price , SUM(CASE WHEN PrevTotal > isNULL(out.Qty, 0) THEN rt.Qty ELSE rt.Total - isNULL(out.Qty,
    0) END * Price) AS Ending , rt.TranDate
    from
        RunningTotals rt
            LEFT join
        TotalOut out
            on
                rt.Stock_ID = out.Stock_ID
    where rt.Total > isNull(out.Qty , 0)
    group by rt.Stock_ID , Price , rt.TranDate  , rt.QTY
    ) SELECT * FROM  GrandTotal  order by TranDate  option (maxrecursion 0)
    AND  this is my Table with some example data
    USE [TestInventory]
    GO
    /****** Object:  Table [dbo].[Tran_Stock]    Script Date: 12/15/2014 3:55:56 AM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[Tran_Stock](
    [TranID] [int] IDENTITY(1,1) NOT NULL,
    [Stock_ID] [int] NULL,
    [TranDate] [date] NULL,
    [TxnType] [nvarchar](3) NULL,
    [Qty] [decimal](10, 2) NULL,
    [Price] [decimal](10, 2) NULL
    ) ON [PRIMARY]
    GO
    SET IDENTITY_INSERT [dbo].[Tran_Stock] ON 
    INSERT [dbo].[Tran_Stock] ([TranID], [Stock_ID], [TranDate], [TxnType], [Qty], [Price]) VALUES (1, 1, CAST(0x81350B00 AS Date), N'IN', CAST(200.00 AS Decimal(10, 2)), CAST(750.00 AS Decimal(10, 2)))
    INSERT [dbo].[Tran_Stock] ([TranID], [Stock_ID], [TranDate], [TxnType], [Qty], [Price]) VALUES (2, 1, CAST(0x85350B00 AS Date), N'OUT', CAST(100.00 AS Decimal(10, 2)), NULL)
    INSERT [dbo].[Tran_Stock] ([TranID], [Stock_ID], [TranDate], [TxnType], [Qty], [Price]) VALUES (3, 1, CAST(0x8A350B00 AS Date), N'IN', CAST(50.00 AS Decimal(10, 2)), CAST(700.00 AS Decimal(10, 2)))
    INSERT [dbo].[Tran_Stock] ([TranID], [Stock_ID], [TranDate], [TxnType], [Qty], [Price]) VALUES (4, 1, CAST(0x90350B00 AS Date), N'IN', CAST(75.00 AS Decimal(10, 2)), CAST(800.00 AS Decimal(10, 2)))
    INSERT [dbo].[Tran_Stock] ([TranID], [Stock_ID], [TranDate], [TxnType], [Qty], [Price]) VALUES (5, 1, CAST(0x99350B00 AS Date), N'OUT', CAST(175.00 AS Decimal(10, 2)), NULL)
    INSERT [dbo].[Tran_Stock] ([TranID], [Stock_ID], [TranDate], [TxnType], [Qty], [Price]) VALUES (6, 2, CAST(0x82350B00 AS Date), N'IN', CAST(150.00 AS Decimal(10, 2)), CAST(350.00 AS Decimal(10, 2)))
    INSERT [dbo].[Tran_Stock] ([TranID], [Stock_ID], [TranDate], [TxnType], [Qty], [Price]) VALUES (7, 2, CAST(0x88350B00 AS Date), N'OUT', CAST(40.00 AS Decimal(10, 2)), NULL)
    INSERT [dbo].[Tran_Stock] ([TranID], [Stock_ID], [TranDate], [TxnType], [Qty], [Price]) VALUES (8, 2, CAST(0x8C350B00 AS Date), N'OUT', CAST(10.00 AS Decimal(10, 2)), NULL)
    INSERT [dbo].[Tran_Stock] ([TranID], [Stock_ID], [TranDate], [TxnType], [Qty], [Price]) VALUES (9, 2, CAST(0x98350B00 AS Date), N'IN', CAST(90.00 AS Decimal(10, 2)), CAST(340.00 AS Decimal(10, 2)))
    INSERT [dbo].[Tran_Stock] ([TranID], [Stock_ID], [TranDate], [TxnType], [Qty], [Price]) VALUES (12, 2, CAST(0x98350B00 AS Date), N'IN', CAST(10.00 AS Decimal(10, 2)), CAST(341.00 AS Decimal(10, 2)))
    INSERT [dbo].[Tran_Stock] ([TranID], [Stock_ID], [TranDate], [TxnType], [Qty], [Price]) VALUES (13, 2, CAST(0x99350B00 AS Date), N'OUT', CAST(30.00 AS Decimal(10, 2)), NULL)
    INSERT [dbo].[Tran_Stock] ([TranID], [Stock_ID], [TranDate], [TxnType], [Qty], [Price]) VALUES (14, 2, CAST(0x81350B00 AS Date), N'IN', CAST(120.00 AS Decimal(10, 2)), CAST(350.00 AS Decimal(10, 2)))
    INSERT [dbo].[Tran_Stock] ([TranID], [Stock_ID], [TranDate], [TxnType], [Qty], [Price]) VALUES (15, 2, CAST(0x89350B00 AS Date), N'OUT', CAST(90.00 AS Decimal(10, 2)), NULL)
    INSERT [dbo].[Tran_Stock] ([TranID], [Stock_ID], [TranDate], [TxnType], [Qty], [Price]) VALUES (17, 3, CAST(0x89350B00 AS Date), N'IN', CAST(90.00 AS Decimal(10, 2)), CAST(350.00 AS Decimal(10, 2)))
    INSERT [dbo].[Tran_Stock] ([TranID], [Stock_ID], [TranDate], [TxnType], [Qty], [Price]) VALUES (18, 3, CAST(0x8A350B00 AS Date), N'OUT', CAST(60.00 AS Decimal(10, 2)), NULL)
    INSERT [dbo].[Tran_Stock] ([TranID], [Stock_ID], [TranDate], [TxnType], [Qty], [Price]) VALUES (19, 3, CAST(0x5D390B00 AS Date), N'OUT', CAST(20.00 AS Decimal(10, 2)), NULL)
    INSERT [dbo].[Tran_Stock] ([TranID], [Stock_ID], [TranDate], [TxnType], [Qty], [Price]) VALUES (20, 1, CAST(0x81350B00 AS Date), N'IN', CAST(200.00 AS Decimal(10, 2)), CAST(750.00 AS Decimal(10, 2)))
    INSERT [dbo].[Tran_Stock] ([TranID], [Stock_ID], [TranDate], [TxnType], [Qty], [Price]) VALUES (21, 1, CAST(0x85350B00 AS Date), N'OUT', CAST(100.00 AS Decimal(10, 2)), NULL)

    Hi,
    You dont have any Index on the table, so the filters (where part in the queries) and the sorting (order by, group by) make your query slow. it take time to sort or filter data without Index. It is like reading a book with 3k pages and trying to find a specific
    subject. You have to read the all books, but if you have "table of contents" which is the book index, then this can be done fast.
    * check the Execution plan (the image here show part of your query's execution plan). the query scan the all table 3 times...
    there is one sort that use 81% of the query resources... I will go sleep soon (it is
    23:58 In Israel now), and I don't know if I will have time to read the query itself and improved it, so lets start with indexes :-) 
    ** as a first step after or before you create the right Indexes you should remove the recursive all together. there is no reason for lopping the data when you can use it as a SET. This is where the relational database's power come to life :-)
    for example check this code. I only use your first part of the code using the first 2 CTE tables. compare result.
    ;WITH
    OrderedIn as (
    select *,ROW_NUMBER() OVER (PARTITION BY Stock_ID ORDER BY TranDate) as rn
    from Tran_Stock
    where TxnType = 'IN'
    , RunningTotals as (
    select Stock_ID ,Qty, Price, Qty as Total, Cast(0 as decimal(10,2)) as PrevTotal, trandate , rn
    from OrderedIn where rn = 1
    union all
    select
    rt.Stock_ID, oi.Qty, oi.Price, Cast(rt.Total + oi.Qty as decimal(10,2))
    ,Cast(rt.Total as decimal(10,2))
    , oi.TranDate ,oi.rn
    from RunningTotals rt
    inner join OrderedIn oi on rt.Stock_ID = oi.Stock_ID and rt.rn = oi.rn - 1
    select * from RunningTotals
    -- This will do the same as the above query
    select
    Stock_ID, Qty, Price
    , SUM(Qty) over (PARTITION BY Stock_ID order by TranDate ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) as Total
    ,TranDate--,TranID, TxnType
    from Tran_Stock
    where TxnType = 'IN'
    order by Stock_ID
      Ronen Ariely
     [Personal Site]    [Blog]    [Facebook]

  • Query is Very Slow but after using sql tuning advisor the Query is fine

    Currently we have Query which takes ages to retrieve small data set of 30 seconds.So i used the sql advisor and applied the profile now the same query comes in msec.This was tested on Test enviorement.
    Metadata for Table: TIBEX_PARTICIPANT
      CREATE TABLE "TST_PRE_EOD"."TIBEX_PARTICIPANT"
       (     "PARTICIPANTID" VARCHAR2(25) NOT NULL ENABLE,
         "PARTICIPANTTYPE" NUMBER(4,0),
         "PARTICIPANTSUBTYPE" VARCHAR2(5),
         "PARTICIPANTSTATUS" NUMBER(4,0),
         "PARTICIPANTNAMESHORT" VARCHAR2(15),
         "PARTICIPANTNAME" VARCHAR2(60),
         "ROOTPARTICIPANTID" VARCHAR2(25),
         "PARENTPARTICIPANTID" VARCHAR2(25),
         "SFAREPORTING" CHAR(1),
         "ADDRESSOFFICENAME" VARCHAR2(30),
         "ADDRESSLINE1" VARCHAR2(60),
         "ADDRESSLINE2" VARCHAR2(40),
         "ADDRESSLINE3" VARCHAR2(50),
         "ADDRESSLINE4" VARCHAR2(50),
         "ADDRESSCOUNTRY" VARCHAR2(50),
         "WEBURL" VARCHAR2(100),
         "PHONENO" VARCHAR2(20),
         "FAXNO" VARCHAR2(20),
         "CONTACTNAME" VARCHAR2(50),
         "CONTACTTITLE" VARCHAR2(30),
         "CONTACTEMAIL" VARCHAR2(35),
         "CURRENTOPENVAL" FLOAT(126) NOT NULL ENABLE,
         "OPENVALLIMIT" FLOAT(126) NOT NULL ENABLE,
         "TIMESTAMP" NUMBER(20,0) NOT NULL ENABLE,
         "ORDERVALLIMIT" FLOAT(126) NOT NULL ENABLE,
         "NOTE" VARCHAR2(50),
         "PARTICIPANTINDEX" NUMBER(4,0),
         "AUTOROUTETOCLEARING" CHAR(1),
         "CREDITID" VARCHAR2(25),
         "ISCPTRDDETAILS" CHAR(1) NOT NULL ENABLE,
         "PRIMARY_BIC" VARCHAR2(11),
         "QSID" VARCHAR2(10) NOT NULL ENABLE,
         "INTERNALISEDTRADES" CHAR(1) NOT NULL ENABLE,
          CONSTRAINT "XPKTIBEX_PARTICIPANT" PRIMARY KEY ("PARTICIPANTID")
      USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "TST_PRE_EOD"  ENABLE
       ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "TST_PRE_EOD" ;
    Back to Metadata
    Back to Top
    Metadata for Table: TIBEX_QUOTE
      CREATE TABLE "TST_PRE_EOD"."TIBEX_QUOTE"
       (     "QUOTEID" CHAR(20) NOT NULL ENABLE,
         "USERORDERID" VARCHAR2(25),
         "QUOTESTATUS" NUMBER(4,0) NOT NULL ENABLE,
         "INDICATIVE" CHAR(1),
         "BOARDID" VARCHAR2(10),
         "INSTRUMENTID" VARCHAR2(50) NOT NULL ENABLE,
         "SELLPRICE" FLOAT(126),
         "SELLQTY" NUMBER(10,0),
         "BUYPRICE" FLOAT(126),
         "BUYQTY" NUMBER(10,0),
         "PARTICIPANTID" VARCHAR2(25),
         "ACCOUNTNO" VARCHAR2(50),
         "LASTINSTRESULT" VARCHAR2(50),
         "LASTINSTMESSAGESEQUENCE" NUMBER(20,0) NOT NULL ENABLE,
         "BUYQUOTEMINSIZE" NUMBER(10,0),
         "LASTEXECUTIONID" CHAR(20),
         "SELLQUOTEMINSIZE" NUMBER(10,0),
         "TICKMOVECOUNT" NUMBER(10,0),
         "TIMESTAMP" NUMBER(20,0) NOT NULL ENABLE,
         "SELLQTYFILLED" NUMBER(10,0),
         "BUYQTYFILLED" NUMBER(10,0),
         "MEID" VARCHAR2(10) NOT NULL ENABLE,
         "LASTINSTREJECTCODE" VARCHAR2(10),
         "LASTEXECPRICE" FLOAT(126),
         "LASTEXECQTY" NUMBER(10,0),
         "LASTEXECSIDE" NUMBER(4,0),
         "LASTINSTTYPE" NUMBER(4,0),
         "LASTEXECUTIONCOUNTERPARTY" VARCHAR2(25),
         "BIDTIMESTAMP" NUMBER(20,0),
         "OFFERTIMESTAMP" NUMBER(20,0),
         "LASTEXECCLEARINGAGENCY" VARCHAR2(11),
         "LASTEXECACCOUNTNO" VARCHAR2(50),
         "LASTEXECCPCLEARINGAGENCY" VARCHAR2(11),
         "LASTEXECBOARDID" VARCHAR2(10),
         "MESSAGESEQUENCE" NUMBER(20,0) NOT NULL ENABLE,
         "LASTINSTUSERALIAS" CHAR(4) NOT NULL ENABLE,
         "PARTNEREXID" CHAR(20),
         "LASTSETTLEMENTCYCLE" NUMBER(4,0),
         "LASTEXECPOSTTRADEVENUETYPE" NUMBER(4,0),
         "PRICELEVELPOSITION" NUMBER(4,0),
         "MATCHTYPE" NUMBER(4,0),
         "LASTEXECUTIONROLE" VARCHAR2(4),
         "REFERENCEID" VARCHAR2(25),
         "BUYMDENTRYID" VARCHAR2(13),
         "SELLMDENTRYID" VARCHAR2(13),
         "HALTREASON" NUMBER(4,0),
         "LASTINSTFIXSEQUENCE" NUMBER(20,0)
       ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "TST_PRE_EOD" ;
    Back to Metadata
    Back to Top
    Metadata for Table: TIBEX_QUOTESTATUSENUM
      CREATE TABLE "TST_PRE_EOD"."TIBEX_QUOTESTATUSENUM"
       (     "QUOTESTATUS" NUMBER(4,0) NOT NULL ENABLE,
         "SHORTDESC" VARCHAR2(32) NOT NULL ENABLE,
         "DESCRIPTION" VARCHAR2(50),
          CONSTRAINT "XPKTIBEX_QUOTESTATUSENUM" PRIMARY KEY ("QUOTESTATUS")
      USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "TST_PRE_EOD"  ENABLE
       ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "TST_PRE_EOD" ;
    Back to Metadata
    Back to Top
    Metadata for Index: IX_QUOTEBOOK
      CREATE INDEX "TST_PRE_EOD"."IX_QUOTEBOOK" ON "TST_PRE_EOD"."TIBEX_QUOTE" ("QUOTEID", "MESSAGESEQUENCE", "QUOTESTATUS")
      PCTFREE 10 INITRANS 2 MAXTRANS 255 NOLOGGING COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "TST_PRE_EOD" ;
    Back to Metadata
    Back to Top
    Metadata for Index: IX_QUOTE_TIMESTAMP
      CREATE INDEX "TST_PRE_EOD"."IX_QUOTE_TIMESTAMP" ON "TST_PRE_EOD"."TIBEX_QUOTE" ("TIMESTAMP")
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "TST_PRE_EOD" ;
    Back to Metadata
    Back to Top
    Metadata for Index: TIBEX_PARTICIPANTQSID
      CREATE INDEX "TST_PRE_EOD"."TIBEX_PARTICIPANTQSID" ON "TST_PRE_EOD"."TIBEX_PARTICIPANT" ("QSID")
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "TST_PRE_EOD" ;
    Back to Metadata
    Back to Top
    Metadata for Index: TIBEX_QUOTE_IDX_QLT
      CREATE INDEX "TST_PRE_EOD"."TIBEX_QUOTE_IDX_QLT" ON "TST_PRE_EOD"."TIBEX_QUOTE" ("LASTINSTUSERALIAS", "TIMESTAMP")
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "TST_PRE_EOD" ;
    Back to Metadata
    Back to Top
    Metadata for Index: XPKTIBEX_PARTICIPANT
      CREATE UNIQUE INDEX "TST_PRE_EOD"."XPKTIBEX_PARTICIPANT" ON "TST_PRE_EOD"."TIBEX_PARTICIPANT" ("PARTICIPANTID")
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "TST_PRE_EOD" ;
    Back to Metadata
    Back to Top
    Metadata for Index: XPKTIBEX_QUOTESTATUSENUM
      CREATE UNIQUE INDEX "TST_PRE_EOD"."XPKTIBEX_QUOTESTATUSENUM" ON "TST_PRE_EOD"."TIBEX_QUOTESTATUSENUM" ("QUOTESTATUS")
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "TST_PRE_EOD" ;
    Back to Metadata
    Back to Top
    Metadata for View: TIBEX_QUOTESBYQSIDVIEW
      CREATE OR REPLACE FORCE VIEW "TST_PRE_EOD"."TIBEX_QUOTESBYQSIDVIEW" ("QUOTEID", "USERORDERID", "QUOTESTATUS", "INDICATIVE", "BOARDID", "INSTRUMENTID", "SELLPRICE", "SELLQTY", "BUYPRICE", "BUYQTY", "PARTICIPANTID", "ACCOUNTNO", "LASTINSTRESULT", "LASTINSTMESSAGESEQUENCE", "BUYQUOTEMINSIZE", "LASTEXECUTIONID", "SELLQUOTEMINSIZE", "TICKMOVECOUNT", "TIMESTAMP", "SELLQTYFILLED", "BUYQTYFILLED", "MEID", "LASTINSTREJECTCODE", "LASTEXECPRICE", "LASTEXECQTY", "LASTEXECSIDE", "LASTINSTTYPE", "LASTEXECUTIONCOUNTERPARTY", "BIDTIMESTAMP", "OFFERTIMESTAMP", "LASTEXECCLEARINGAGENCY", "LASTEXECACCOUNTNO", "LASTEXECCPCLEARINGAGENCY", "LASTEXECBOARDID", "MESSAGESEQUENCE", "LASTINSTUSERALIAS", "PARTNEREXID", "LASTSETTLEMENTCYCLE", "LASTEXECPOSTTRADEVENUETYPE", "PRICELEVELPOSITION", "MATCHTYPE", "LASTEXECUTIONROLE", "REFERENCEID", "BUYMDENTRYID", "SELLMDENTRYID", "HALTREASON", "LASTINSTFIXSEQUENCE", "QSID") AS
      SELECT  a.QUOTEID, a.USERORDERID, a.QUOTESTATUS, a.INDICATIVE, a.BOARDID,
           a.INSTRUMENTID, a.SELLPRICE, a.SELLQTY, a.BUYPRICE, a.BUYQTY,
           a.PARTICIPANTID, a.ACCOUNTNO, a.LASTINSTRESULT,
           a.LASTINSTMESSAGESEQUENCE, a.BUYQUOTEMINSIZE, a.LASTEXECUTIONID,
           a.SELLQUOTEMINSIZE, a.TICKMOVECOUNT, a.TIMESTAMP,
           a.SELLQTYFILLED, a.BUYQTYFILLED, a.MEID, a.LASTINSTREJECTCODE,
           a.LASTEXECPRICE, a.LASTEXECQTY, a.LASTEXECSIDE, a.LASTINSTTYPE,
           a.LASTEXECUTIONCOUNTERPARTY, a.BIDTIMESTAMP, a.OFFERTIMESTAMP,
           a.LASTEXECCLEARINGAGENCY, a.LASTEXECACCOUNTNO,
           a.LASTEXECCPCLEARINGAGENCY, a.LASTEXECBOARDID,
           a.MESSAGESEQUENCE, a.LASTINSTUSERALIAS, a.PARTNEREXID,
           a.LASTSETTLEMENTCYCLE, a.LASTEXECPOSTTRADEVENUETYPE,
           a.PRICELEVELPOSITION, a.MATCHTYPE, a.LASTEXECUTIONROLE,
           a.referenceID, a.BuyMDEntryID, a.SellMDEntryID, a.haltReason,
           a.lastInstFixSequence, b.QSID
        FROM  tibex_quote A,
              tibex_Participant b
        WHERE a.participantID = b.participantID
          AND (A.MessageSequence, A.QuoteID) IN (
                SELECT  max(C.MessageSequence), C.quoteID
                  FROM  tibex_quote C
                  WHERE LastInstRejectCode = 'OK'
                  GROUP By C.QuoteID
          AND a.QuoteStatus IN (
                SELECT QuoteStatus
                  FROM tibex_quoteStatusEnum
                  WHERE ShortDesc IN (
                          'QUO_ONMKT', 'QUO_OFFMKT', 'QUO_PREOPN'
              );Tkprof in Next post

    Tkprof Details
    TKPROF: Release 10.2.0.4.0 - Production on Thu Jan 28 14:38:44 2010
    Copyright (c) 1982, 2007, Oracle.  All rights reserved.
    Trace file: mifex3_ora_2598_mytrace1.trc
    Sort options: default
    count    = number of times OCI procedure was executed
    cpu      = cpu time in seconds executing
    elapsed  = elapsed time in seconds executing
    disk     = number of physical reads of buffers from disk
    query    = number of buffers gotten for consistent read
    current  = number of buffers gotten in current mode (usually for update)
    rows     = number of rows processed by the fetch or execute call
    BEGIN DBMS_OUTPUT.GET_LINES(:LINES, :NUMLINES); END;
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        2      0.00       0.00          0          0          0           0
    Execute      2      0.00       0.00          0          0          0           2
    Fetch        0      0.00       0.00          0          0          0           0
    total        4      0.00       0.00          0          0          0           2
    Misses in library cache during parse: 0
    Optimizer mode: ALL_ROWS
    Parsing user id: 163 
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      SQL*Net message to client                       3        0.00          0.00
      SQL*Net message from client                     3        0.00          0.00
    select text
    from
    view$ where rowid=:1
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        2      0.00       0.00          0          0          0           0
    Execute      2      0.00       0.02          0          0          0           0
    Fetch        2      0.00       0.00          0          4          0           2
    total        6      0.00       0.02          0          4          0           2
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: CHOOSE
    Parsing user id: SYS   (recursive depth: 1)
    Rows     Row Source Operation
          1  TABLE ACCESS BY USER ROWID VIEW$ (cr=1 pr=0 pw=0 time=18 us)
    SELECT quoteid, lastexecposttradevenuetype, lastexecqty, matchtype,
           haltreason, buyquoteminsize, meid, lastinstuseralias, boardid,
           userorderid, buymdentryid, indicative, lastinsttype, lastexecprice,
           buyprice, partnerexid, lastinstresult, pricelevelposition,
           lastinstrejectcode, TIMESTAMP, buyqtyfilled, referenceid,
           lastexecboardid, bidtimestamp, tickmovecount, lastexecside,
           offertimestamp, sellprice, participantid, lastexecutioncounterparty,
           lastexecaccountno, sellmdentryid, accountno, buyqty, messagesequence,
           lastexecutionid, lastexeccpclearingagency, sellqty,
           lastexecclearingagency, sellquoteminsize, lastinstfixsequence,
           quotestatus, lastinstmessagesequence, instrumentid, sellqtyfilled,
           lastexecutionrole, lastsettlementcycle
      FROM tibex_quotesbyqsidview
    WHERE participantid = 'NITE'
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.01       0.02          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        6     21.43      20.94       1125    2405864          0         468
    total        8     21.44      20.97       1125    2405864          0         468
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 163 
    Rows     Row Source Operation
        468  FILTER  (cr=2405864 pr=1125 pw=1125 time=20927185 us)
      24523   HASH GROUP BY (cr=2405864 pr=1125 pw=1125 time=21171165 us)
    2994085    TABLE ACCESS BY INDEX ROWID TIBEX_QUOTE (cr=2405864 pr=0 pw=0 time=8983645 us)
    3076661     NESTED LOOPS  (cr=87651 pr=0 pw=0 time=3092729 us)
      24523      HASH JOIN  (cr=18276 pr=0 pw=0 time=173004 us)
          3       NESTED LOOPS  (cr=8 pr=0 pw=0 time=81 us)
          1        INDEX UNIQUE SCAN XPKTIBEX_PARTICIPANT (cr=1 pr=0 pw=0 time=18 us)(object id 168573)
          3        TABLE ACCESS FULL TIBEX_QUOTESTATUSENUM (cr=7 pr=0 pw=0 time=55 us)
      24523       TABLE ACCESS FULL TIBEX_QUOTE (cr=18268 pr=0 pw=0 time=122762 us)
    3052137      INDEX RANGE SCAN IX_QUOTEBOOK (cr=69375 pr=0 pw=0 time=195648 us)(object id 168590)
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      SQL*Net message to client                       6        0.00          0.00
      SQL*Net more data to client                    46        0.00          0.00
      direct path write temp                         75        0.00          0.04
      SQL*Net message from client                     6        0.00          0.00
      direct path read temp                          75        0.00          0.00
    DELETE FROM PLAN_TABLE
    WHERE
    STATEMENT_ID=:1
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        2      0.00       0.00          0          0          0           0
    Execute      2      0.00       0.04          0          9         16          11
    Fetch        0      0.00       0.00          0          0          0           0
    total        4      0.00       0.04          0          9         16          11
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 163 
    Rows     Row Source Operation
          0  DELETE  PLAN_TABLE$ (cr=4 pr=0 pw=0 time=33 us)
          0   TABLE ACCESS FULL PLAN_TABLE$ (cr=4 pr=0 pw=0 time=30 us)
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      SQL*Net message to client                       2        0.00          0.00
      SQL*Net message from client                     2        0.01          0.02
    SELECT /* OPT_DYN_SAMP */ /*+ ALL_ROWS IGNORE_WHERE_CLAUSE
      NO_PARALLEL(SAMPLESUB) opt_param('parallel_execution_enabled', 'false')
      NO_PARALLEL_INDEX(SAMPLESUB) NO_SQL_TUNE */ NVL(SUM(C1),0), NVL(SUM(C2),0)
    FROM
    (SELECT /*+ IGNORE_WHERE_CLAUSE NO_PARALLEL("PLAN_TABLE") FULL("PLAN_TABLE")
      NO_PARALLEL_INDEX("PLAN_TABLE") */ 1 AS C1, CASE WHEN
      "PLAN_TABLE"."STATEMENT_ID"=:B1 THEN 1 ELSE 0 END AS C2 FROM
      "SYS"."PLAN_TABLE$" "PLAN_TABLE") SAMPLESUB
    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        1      0.00       0.00          0          4          0           1
    total        3      0.00       0.00          0          4          0           1
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 163     (recursive depth: 1)
    Rows     Row Source Operation
          1  SORT AGGREGATE (cr=4 pr=0 pw=0 time=56 us)
          0   TABLE ACCESS FULL PLAN_TABLE$ (cr=4 pr=0 pw=0 time=43 us)
    EXPLAIN PLAN SET STATEMENT_ID='PLUS8205116' FOR SELECT quoteid, lastexecposttradevenuetype, lastexecqty, matchtype,
           haltreason, buyquoteminsize, meid, lastinstuseralias, boardid,
           userorderid, buymdentryid, indicative, lastinsttype, lastexecprice,
           buyprice, partnerexid, lastinstresult, pricelevelposition,
           lastinstrejectcode, TIMESTAMP, buyqtyfilled, referenceid,
           lastexecboardid, bidtimestamp, tickmovecount, lastexecside,
           offertimestamp, sellprice, participantid, lastexecutioncounterparty,
           lastexecaccountno, sellmdentryid, accountno, buyqty, messagesequence,
           lastexecutionid, lastexeccpclearingagency, sellqty,
           lastexecclearingagency, sellquoteminsize, lastinstfixsequence,
           quotestatus, lastinstmessagesequence, instrumentid, sellqtyfilled,
           lastexecutionrole, lastsettlementcycle
      FROM tibex_quotesbyqsidview
    WHERE participantid = 'NITE'
    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        0      0.00       0.00          0          0          0           0
    total        2      0.01       0.01          0          0          0           0
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 163 
    Rows     Row Source Operation
          0  FILTER  (cr=0 pr=0 pw=0 time=0 us)
          0   HASH GROUP BY (cr=0 pr=0 pw=0 time=0 us)
          0    TABLE ACCESS BY INDEX ROWID TIBEX_QUOTE (cr=0 pr=0 pw=0 time=0 us)
          0     NESTED LOOPS  (cr=0 pr=0 pw=0 time=0 us)
          0      HASH JOIN  (cr=0 pr=0 pw=0 time=0 us)
          0       NESTED LOOPS  (cr=0 pr=0 pw=0 time=0 us)
          0        INDEX UNIQUE SCAN XPKTIBEX_PARTICIPANT (cr=0 pr=0 pw=0 time=0 us)(object id 168573)
          0        TABLE ACCESS FULL TIBEX_QUOTESTATUSENUM (cr=0 pr=0 pw=0 time=0 us)
          0       TABLE ACCESS FULL TIBEX_QUOTE (cr=0 pr=0 pw=0 time=0 us)
          0      INDEX RANGE SCAN IX_QUOTEBOOK (cr=0 pr=0 pw=0 time=0 us)(object id 168590)
    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
    insert into plan_table (statement_id, timestamp, operation, options,
      object_node, object_owner, object_name, object_instance, object_type,
      search_columns, id, parent_id, position, other,optimizer, cost, cardinality,
       bytes, other_tag, partition_start, partition_stop, partition_id,
      distribution, cpu_cost, io_cost, temp_space, access_predicates,
      filter_predicates, projection, time, qblock_name, object_alias, plan_id,
      depth, remarks, other_xml )
    values
    (:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12,:13,:14,:15,:16,:17,:18,:19,:20,:21,
      :22,:23,:24,:25,:26,:27,:28,:29,:30,:31,:32,:33,:34,:35,:36)
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute     11      0.00       0.03          0          4         16          11
    Fetch        0      0.00       0.00          0          0          0           0
    total       12      0.00       0.03          0          4         16          11
    Misses in library cache during parse: 1
    Misses in library cache during execute: 3
    Optimizer mode: ALL_ROWS
    Parsing user id: 163     (recursive depth: 1)
    SELECT ORA_PLAN_ID_SEQ$.NEXTVAL
    FROM
    DUAL
    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        1      0.00       0.00          0          0          0           1
    total        3      0.00       0.00          0          0          0           1
    Misses in library cache during parse: 1
    Optimizer mode: CHOOSE
    Parsing user id: SYS   (recursive depth: 1)
    Rows     Row Source Operation
          1  SEQUENCE  ORA_PLAN_ID_SEQ$ (cr=0 pr=0 pw=0 time=18 us)
          1   FAST DUAL  (cr=0 pr=0 pw=0 time=2 us)
    SELECT PLAN_TABLE_OUTPUT
    FROM
    TABLE(DBMS_XPLAN.DISPLAY('PLAN_TABLE', :1))
    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        117          0           0
    Fetch        2      0.00       0.00          0          0          0          28
    total        4      0.00       0.00          0        117          0          28
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 163 
    Rows     Row Source Operation
         28  COLLECTION ITERATOR PICKLER FETCH DISPLAY (cr=202 pr=0 pw=0 time=19391 us)
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      SQL*Net message to client                       2        0.00          0.00
      SQL*Net message from client                     2        0.00          0.00
      SQL*Net more data to client                     1        0.00          0.00
    select u.name, o.name, a.interface_version#, o.obj#     
    from
    association$ a, user$ u, obj$ o                     where a.obj# = :1       
                                        and a.property = :2                      
                     and a.statstype# = o.obj#                                and
      u.user# = o.owner#
    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        1      0.00       0.00          0          1          0           0
    total        3      0.00       0.00          0          1          0           0
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: CHOOSE
    Parsing user id: SYS   (recursive depth: 1)
    Rows     Row Source Operation
          0  NESTED LOOPS  (cr=1 pr=0 pw=0 time=32 us)
          0   NESTED LOOPS  (cr=1 pr=0 pw=0 time=30 us)
          0    TABLE ACCESS BY INDEX ROWID ASSOCIATION$ (cr=1 pr=0 pw=0 time=27 us)
          0     INDEX RANGE SCAN ASSOC1 (cr=1 pr=0 pw=0 time=23 us)(object id 387)
          0    TABLE ACCESS BY INDEX ROWID OBJ$ (cr=0 pr=0 pw=0 time=0 us)
          0     INDEX UNIQUE SCAN I_OBJ1 (cr=0 pr=0 pw=0 time=0 us)(object id 36)
          0   TABLE ACCESS CLUSTER USER$ (cr=0 pr=0 pw=0 time=0 us)
          0    INDEX UNIQUE SCAN I_USER# (cr=0 pr=0 pw=0 time=0 us)(object id 11)
    SELECT /* OPT_DYN_SAMP */ /*+ ALL_ROWS IGNORE_WHERE_CLAUSE
      NO_PARALLEL(SAMPLESUB) opt_param('parallel_execution_enabled', 'false')
      NO_PARALLEL_INDEX(SAMPLESUB) NO_SQL_TUNE */ NVL(SUM(C1),:"SYS_B_0"),
      NVL(SUM(C2),:"SYS_B_1")
    FROM
    (SELECT /*+ NO_PARALLEL("PLAN_TABLE") FULL("PLAN_TABLE")
      NO_PARALLEL_INDEX("PLAN_TABLE") */ :"SYS_B_2" AS C1, :"SYS_B_3" AS C2 FROM
      "SYS"."PLAN_TABLE$" "PLAN_TABLE") SAMPLESUB
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        2      0.00       0.00          0          0          0           0
    Execute      2      0.00       0.00          0          0          0           0
    Fetch        2      0.00       0.00          0          8          0           2
    total        6      0.00       0.00          0          8          0           2
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 163     (recursive depth: 2)
    Rows     Row Source Operation
          1  SORT AGGREGATE (cr=4 pr=0 pw=0 time=55 us)
         11   TABLE ACCESS FULL PLAN_TABLE$ (cr=4 pr=0 pw=0 time=44 us)
    select /*+ opt_param('parallel_execution_enabled',
                                       'false') EXEC_FROM_DBMS_XPLAN */ * from PLAN_TABLE where 1=0
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          1          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        0      0.00       0.00          0          0          0           0
    total        2      0.00       0.00          0          1          0           0
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 163     (recursive depth: 1)
    Rows     Row Source Operation
          0  FILTER  (cr=0 pr=0 pw=0 time=1 us)
          0   TABLE ACCESS FULL PLAN_TABLE$ (cr=0 pr=0 pw=0 time=0 us)
    SELECT /*+ opt_param('parallel_execution_enabled', 'false') */
                             /* EXEC_FROM_DBMS_XPLAN */ id, position, depth, operation, options, object_name, cardinality, bytes, temp_space, cost, io_cost, cpu_cost , time, partition_start, partition_stop, object_node, other_tag, distribution, projection, access_predicates, filter_predicates , other, qblock_name, object_alias, nvl(other_xml, remarks), null, null, null, null, null, null, null,
                                null, null, null, null, null,
                                null, null, null, null from PLAN_TABLE where plan_id = (select max(plan_id)
                                            from PLAN_TABLE where id=0  and statement_id = :stmt_id)
                           order by id
    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          2          0           0
    Fetch       12      0.00       0.00          0          8          7          11
    total       14      0.00       0.00          0         10          7          11
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 163     (recursive depth: 2)
    Rows     Row Source Operation
         11  SORT ORDER BY (cr=8 pr=0 pw=0 time=239 us)
         11   TABLE ACCESS FULL PLAN_TABLE$ (cr=8 pr=0 pw=0 time=117 us)
          1    SORT AGGREGATE (cr=4 pr=0 pw=0 time=30 us)
          1     TABLE ACCESS FULL PLAN_TABLE$ (cr=4 pr=0 pw=0 time=21 us)
    SELECT /* OPT_DYN_SAMP */ /*+ ALL_ROWS IGNORE_WHERE_CLAUSE
      NO_PARALLEL(SAMPLESUB) opt_param('parallel_execution_enabled', 'false')
      NO_PARALLEL_INDEX(SAMPLESUB) NO_SQL_TUNE */ NVL(SUM(C1),0), NVL(SUM(C2),0)
    FROM
    (SELECT /*+ IGNORE_WHERE_CLAUSE NO_PARALLEL("PLAN_TABLE") FULL("PLAN_TABLE")
      NO_PARALLEL_INDEX("PLAN_TABLE") */ 1 AS C1, CASE WHEN "PLAN_TABLE"."ID"=0
      AND "PLAN_TABLE"."STATEMENT_ID"=:B1 THEN 1 ELSE 0 END AS C2 FROM
      "SYS"."PLAN_TABLE$" "PLAN_TABLE") SAMPLESUB
    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        1      0.00       0.00          0          4          0           1
    total        3      0.00       0.00          0          4          0           1
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 163     (recursive depth: 2)
    Rows     Row Source Operation
          1  SORT AGGREGATE (cr=4 pr=0 pw=0 time=57 us)
         11   TABLE ACCESS FULL PLAN_TABLE$ (cr=4 pr=0 pw=0 time=44 us)
    SELECT PLAN_TABLE_OUTPUT
    FROM
    TABLE(CAST(DBMS_XPLAN.PREPARE_RECORDS(:B1 , :B2 ) AS
      SYS.DBMS_XPLAN_TYPE_TABLE))
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        0      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        1      0.00       0.00          0          5          5          28
    total        2      0.00       0.00          0          5          5          28
    Misses in library cache during parse: 0
    Optimizer mode: ALL_ROWS
    Parsing user id: 163     (recursive depth: 1)
    SELECT /*+ opt_param('parallel_execution_enabled', 'false') */
      extractvalue(xmlval, '/*/info[@type = "sql_profile"]'), extractvalue(xmlval,
       '/*/info[@type = "outline"]'), extractvalue(xmlval, '/*/info[@type =
      "dynamic_sampling"]'), extractvalue(xmlval, '/*/info[@type =
      "row_shipping"]'), extractvalue(xmlval, '/*/info[@type = "index_size"]'),
      extractvalue(xmlval,'/*/info[@type = "plan_hash"]')
    from
    (select xmltype(:v_other_xml) xmlval from dual)
    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        150          0           0
    Fetch        1      0.00       0.00          0         24          0           1
    total        3      0.01       0.01          0        174          0           1
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 163     (recursive depth: 2)
    Rows     Row Source Operation
          1  FAST DUAL  (cr=0 pr=0 pw=0 time=3 us)
    OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        7      0.01       0.03          0          0          0           0
    Execute      7      0.01       0.04          0        126         16          13
    Fetch        8     21.43      20.94       1125    2405864          0         496
    total       22     21.46      21.02       1125    2405990         16         509
    Misses in library cache during parse: 4
    Misses in library cache during execute: 2
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      SQL*Net message to client                      14        0.00          0.00
      SQL*Net message from client                    14        0.01          0.03
      SQL*Net more data to client                    47        0.00          0.00
      direct path write temp                         75        0.00          0.04
      direct path read temp                          75        0.00          0.00
      log file sync                                   1        0.00          0.00
    OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
    call     count       cpu    elapsed       disk      query    current        rows
    Parse       12      0.00       0.00          0          1          0           0
    Execute     23      0.01       0.07          0        156         16          11
    Fetch       22      0.00       0.00          0         58         12          47
    total       57      0.02       0.08          0        215         28          58
    Misses in library cache during parse: 10
    Misses in library cache during execute: 10
       16  user  SQL statements in session.
        4  internal SQL statements in session.
       20  SQL statements in session.
    Trace file: mifex3_ora_2598_mytrace1.trc
    Trace file compatibility: 10.01.00
    Sort options: default
           4  sessions in tracefile.
          35  user  SQL statements in trace file.
           9  internal SQL statements in trace file.
          20  SQL statements in trace file.
          16  unique SQL statements in trace file.
         493  lines in trace file.
          21  elapsed seconds in trace file.

  • SQL Query running really slow, any help in improving will be Great!

    Hi,
    I am really new to this performance tuning and optimization techniques. Explain plan also, I only have theoretical knowledge, no clues on how to find out the real issue which is making the query slow..So if anyone can give me a good direction on where to start even, it will be great..
    Now, my issue is, I have a query which runs really really slow. If I run this query for a small subset of data, it runs fast(Its flying, actually..) but if I give the same query for everything(Full required data), its running for ages..(Actually it is running for 2 days now and still running.)
    I am pasting my query here, the output shows that the query stucks after "Table created"
    SQL> @routinginfo
    Table dropped.
    Table created.
    Please please help!
    I also ran explain plan for this query and there are a number of rows in the plan_table now..
    SORRY!IS there a way to insert a file here, as I want to attach my explain plan also?
    My query -Routinginfo.sql
    set trimspool on
    set heading on
    set verify on
    set serveroutput on
    drop table routinginfo;
    CREATE TABLE routinginfo
    ( POST_TOWN_NAME        VARCHAR2(22 BYTE),
      DELIVERY_OFFICE_NAME  VARCHAR2(40 BYTE),
      ROUTE_ID              NUMBER(10),
      ROUTE_NAME            VARCHAR2(40 BYTE),
      BUILDING_ID           NUMBER(10),
      SUB_BUILDING_ID       NUMBER(10),
      SEQUENCE_NO           NUMBER(4),
      PERSONAL_NAME         VARCHAR2(60 BYTE),
      ADDRESS               VARCHAR2(1004 BYTE),
      BUILDING_USE          VARCHAR2(1 BYTE),
      COMMENTS              VARCHAR2(200 BYTE),
      EAST                  NUMBER(17,5),
      NORTH                 NUMBER(17,5)
    insert into routinginfo
    (post_town_name,delivery_office_name,route_id,route_name,
    building_id,sub_building_id,sequence_no,personal_name,
    address,building_use,comments,east,north)
    select
       p.name,
       d.name,
      b.route_id,
      r.name,
      b.building_id,
      s.sub_build_id,
      b.sequence_no,
      b.personal_name,
      ad.addr_line_1||' '||ad.addr_line_2||' '||ad.addr_line_3||' '||ad.addr_line_4||' '||ad.addr_line_5,
      b.building_use,
      rtrim(replace(b.comments,chr(10),'')),
      b.east,
      b.north
    from t_buildings b,
         (select * from t_sub_buildings where nvl(invalid,'N') = 'N') s,
         t_routes r,
         t_delivery_offices d,
         t_post_towns p,
         t_address_model ad
    where b.building_id = s.building_id(+)
    and   s.building_id is null
    and   r.route_id=b.route_id
    and   (nvl(b.residential_delivery_points,0) > 0 OR nvl(b.commercial_delivery_points,0) > 0)
    and   r.delivery_office_id=d.delivery_office_id
    --and   r.delivery_office_id=303
    and   D.POST_TOWN_ID=P.post_town_id
    and   ad.building_id=b.building_id
    and   ad.sub_building_id is null
    and   nvl(b.invalid, 'N') = 'N'
    and   nvl(b.derelict, 'N') = 'N'
    union
    select
    p.name,
    d.name ,
      b.route_id ,
      r.name ,
      b.building_id ,
      s.sub_build_id ,
      NVL(s.sequence_no,b.sequence_no),
      b.personal_name ,
      ad.addr_line_1||' '||ad.addr_line_2||' '||ad.addr_line_3||' '||ad.addr_line_4||' '||ad.addr_line_5,
      b.building_use,
      rtrim(replace(b.comments,chr(10),'')),
      b.east,
      b.north
    from t_buildings b,
         (select * from t_sub_buildings where nvl(invalid,'N') = 'N') s,
         t_routes r,
         t_delivery_offices d,
         t_post_towns p,
         t_address_model ad
    where s.building_id = b.building_id
    and   r.route_id = s.route_id
    and   (nvl(b.residential_delivery_points,0) > 0 OR nvl(b.commercial_delivery_points,0) > 0)
    and   r.delivery_office_id=d.delivery_office_id
    --and   r.delivery_office_id=303
    and   D.POST_TOWN_ID=P.post_town_id
    and   ad.building_id=b.building_id
    and   ad.sub_building_id = s.sub_build_id
    and   nvl(b.invalid, 'N') = 'N'
    and   nvl(b.derelict, 'N') = 'N'
    union
    select
    p.name,
    d.name,
      b.route_id ,
      r.name ,
      b.building_id,
      s.sub_build_id  ,
      NVL(s.sequence_no,b.sequence_no) ,
      b.personal_name ,
      ad.addr_line_1||' '||ad.addr_line_2||' '||ad.addr_line_3||' '||ad.addr_line_4||' '||ad.addr_line_5 ,
      b.building_use,
      rtrim(replace(b.comments,chr(10),'')),
      b.east,
      b.north
    from t_buildings b,
         (select * from t_sub_buildings where nvl(invalid,'N') = 'N') s,
         t_routes r,
         t_delivery_offices d,
         t_post_towns p,
         t_localities l,
         t_localities lo,
         t_localities loc,
         t_tlands tl,
         t_address_model ad
    where s.building_id = b.building_id
    and   s.route_id is null
    and   r.route_id = b.route_id
    and   (nvl(b.residential_delivery_points,0) > 0 OR nvl(b.commercial_delivery_points,0) > 0)
    and   r.delivery_office_id=d.delivery_office_id
    --and   r.delivery_office_id=303
    and   D.POST_TOWN_ID=P.post_town_id
    and   ad.building_id=b.building_id
    and   ad.sub_building_id = s.sub_build_id
    and   nvl(b.invalid, 'N') = 'N'
    and   nvl(b.derelict, 'N') = 'N';
    commit; Edited by: Krithi on 16-Jun-2009 01:48
    Edited by: Krithi on 16-Jun-2009 01:51
    Edited by: Krithi on 16-Jun-2009 02:44

    This link is helpful alright..but as a beginner, it is taking me too long to understand..But I am going to learn the techniques for sure..
    Fo the time being,I am pasting my explain plan for the above query here, so that I hope any expert can really help me on this one..
    STATEMENT_ID     TIMESTAMP     REMARKS     OPERATION     OPTIONS     OBJECT_NODE     OBJECT_OWNER     OBJECT_NAME     OBJECT_INSTANCE     OBJECT_TYPE     OPTIMIZER     SEARCH_COLUMNS     ID     PARENT_ID     POSITION     COST     CARDINALITY     BYTES
         06/16/2009 09:33:01          SELECT STATEMENT                                   CHOOSE          0          829,387,159,200     829,387,159,200     3,720,524,291,654,720     703,179,091,122,042,000
         06/16/2009 09:33:01          SORT     UNIQUE                                        1     0     1     829,387,159,200     3,720,524,291,654,720     703,179,091,122,042,000
         06/16/2009 09:33:01          UNION-ALL                                             2     1     1               
         06/16/2009 09:33:01          HASH JOIN                                             3     2     1     11,209     87,591     15,853,971
         06/16/2009 09:33:01          FILTER                                             4     3     1               
         06/16/2009 09:33:01          HASH JOIN     OUTER                                        5     4     1               
         06/16/2009 09:33:01          HASH JOIN                                             6     5     1     5,299     59,325     6,585,075
         06/16/2009 09:33:01          VIEW               GEO2     index$_join$_006     6                    7     6     1     4     128     1,792
         06/16/2009 09:33:01          HASH JOIN                                             8     7     1     5,299     59,325     6,585,075
         06/16/2009 09:33:01          INDEX     FAST FULL SCAN          GEO2     POST_TOWN_NAME_I          NON-UNIQUE     ANALYZED          9     8     1     1     128     1,792
         06/16/2009 09:33:01          INDEX     FAST FULL SCAN          GEO2     POST_TOWN_PK          UNIQUE     ANALYZED          10     8     2     1     128     1,792
         06/16/2009 09:33:01          HASH JOIN                                             11     6     2     5,294     59,325     5,754,525
         06/16/2009 09:33:01          TABLE ACCESS     FULL          GEO2     T_DELIVERY_OFFICES     5          ANALYZED          12     11     1     7     586     10,548
         06/16/2009 09:33:01          HASH JOIN                                             13     11     2     5,284     59,325     4,686,675
         06/16/2009 09:33:01          TABLE ACCESS     FULL          GEO2     T_ROUTES     4          ANALYZED          14     13     1     7     4,247     118,916
         06/16/2009 09:33:01          TABLE ACCESS     FULL          GEO2     T_BUILDINGS     1          ANALYZED          15     13     2     5,265     59,408     3,029,808
         06/16/2009 09:33:01          TABLE ACCESS     FULL          GEO2     T_SUB_BUILDINGS     3          ANALYZED          16     5     2     851     278,442     3,898,188
         06/16/2009 09:33:01          TABLE ACCESS     FULL          GEO2     T_ADDRESS_MODEL     7          ANALYZED          17     3     2     3,034     1,582,421     88,615,576
         06/16/2009 09:33:01          NESTED LOOPS                                             18     2     2     10,217     1     189
         06/16/2009 09:33:01          NESTED LOOPS                                             19     18     1     10,216     1     175
         06/16/2009 09:33:01          HASH JOIN                                             20     19     1     10,215     1     157
         06/16/2009 09:33:01          HASH JOIN                                             21     20     1     6,467     80,873     8,168,173
         06/16/2009 09:33:01          TABLE ACCESS     FULL          GEO2     T_ROUTES     11          ANALYZED          22     21     1     7     4,247     118,916
         06/16/2009 09:33:01          HASH JOIN                                             23     21     2     6,440     80,924     5,907,452
         06/16/2009 09:33:01          TABLE ACCESS     FULL          GEO2     T_BUILDINGS     8          ANALYZED          24     23     1     5,265     59,408     3,029,808
         06/16/2009 09:33:01          TABLE ACCESS     FULL          GEO2     T_SUB_BUILDINGS     10          ANALYZED          25     23     2     851     278,442     6,125,724
         06/16/2009 09:33:01          TABLE ACCESS     FULL          GEO2     T_ADDRESS_MODEL     14          ANALYZED          26     20     2     3,034     556,000     31,136,000
         06/16/2009 09:33:01          TABLE ACCESS     BY INDEX ROWID          GEO2     T_DELIVERY_OFFICES     12          ANALYZED          27     19     2     1     1     18
         06/16/2009 09:33:01          INDEX     UNIQUE SCAN          GEO2     DELIVERY_OFFICE_PK          UNIQUE     ANALYZED     1     28     27     1          1     
         06/16/2009 09:33:01          TABLE ACCESS     BY INDEX ROWID          GEO2     T_POST_TOWNS     13          ANALYZED          29     18     2     1     1     14
         06/16/2009 09:33:01          INDEX     UNIQUE SCAN          GEO2     POST_TOWN_PK          UNIQUE     ANALYZED     1     30     29     1          1     
         06/16/2009 09:33:01          MERGE JOIN     CARTESIAN                                        31     2     3     806,976,583,802     3,720,524,291,567,130     703,179,091,106,188,000
         06/16/2009 09:33:01          MERGE JOIN     CARTESIAN                                        32     31     1     16,902,296     73,359,971,046     13,865,034,527,694
         06/16/2009 09:33:01          MERGE JOIN     CARTESIAN                                        33     32     1     1,860     1,207,174     228,155,886
         06/16/2009 09:33:01          MERGE JOIN     CARTESIAN                                        34     33     1     1,580     20     3,780
         06/16/2009 09:33:01          NESTED LOOPS                                             35     34     1     1,566     1     189
         06/16/2009 09:33:01          NESTED LOOPS                                             36     35     1     1,565     1     175
         06/16/2009 09:33:01          NESTED LOOPS                                             37     36     1     1,564     1     157
         06/16/2009 09:33:01          NESTED LOOPS                                             38     37     1     1,563     1     129
         06/16/2009 09:33:01          NESTED LOOPS                                             39     38     1     1,207     178     12,994
         06/16/2009 09:33:01          TABLE ACCESS     FULL          GEO2     T_SUB_BUILDINGS     17          ANALYZED          40     39     1     851     178     3,916
         06/16/2009 09:33:01          TABLE ACCESS     BY INDEX ROWID          GEO2     T_BUILDINGS     15          ANALYZED          41     39     2     2     1     51
         06/16/2009 09:33:01          INDEX     UNIQUE SCAN          GEO2     BUILDING_PK          UNIQUE     ANALYZED     1     42     41     1     1     31     
         06/16/2009 09:33:01          TABLE ACCESS     BY INDEX ROWID          GEO2     T_ADDRESS_MODEL     25          ANALYZED          43     38     2     2     1     56
         06/16/2009 09:33:01          INDEX     UNIQUE SCAN          GEO2     MODEL_MODEL2_UK          UNIQUE     ANALYZED     2     44     43     1     1     1     
         06/16/2009 09:33:01          TABLE ACCESS     BY INDEX ROWID          GEO2     T_ROUTES     18          ANALYZED          45     37     2     1     1     28
         06/16/2009 09:33:01          INDEX     UNIQUE SCAN          GEO2     ROUTE_PK          UNIQUE     ANALYZED     1     46     45     1          1     
         06/16/2009 09:33:01          TABLE ACCESS     BY INDEX ROWID          GEO2     T_DELIVERY_OFFICES     19          ANALYZED          47     36     2     1     1     18
         06/16/2009 09:33:01          INDEX     UNIQUE SCAN          GEO2     DELIVERY_OFFICE_PK          UNIQUE     ANALYZED     1     48     47     1          1     
         06/16/2009 09:33:01          TABLE ACCESS     BY INDEX ROWID          GEO2     T_POST_TOWNS     20          ANALYZED          49     35     2     1     1     14
         06/16/2009 09:33:01          INDEX     UNIQUE SCAN          GEO2     POST_TOWN_PK          UNIQUE     ANALYZED     1     50     49     1          1     
         06/16/2009 09:33:01          BUFFER     SORT                                        51     34     2     1,579     60,770     
         06/16/2009 09:33:01          INDEX     FAST FULL SCAN          GEO2     LOCAL_COUNTY_FK_I          NON-UNIQUE     ANALYZED          52     51     1     14     60,770     
         06/16/2009 09:33:01          BUFFER     SORT                                        53     33     2     1,846     60,770     
         06/16/2009 09:33:01          INDEX     FAST FULL SCAN          GEO2     LOCAL_COUNTY_FK_I          NON-UNIQUE     ANALYZED          54     53     1     14     60,770     
         06/16/2009 09:33:01          BUFFER     SORT                                        55     32     2     16,902,282     60,770     
         06/16/2009 09:33:01          INDEX     FAST FULL SCAN          GEO2     LOCAL_COUNTY_FK_I          NON-UNIQUE     ANALYZED          56     55     1     14     60,770     
         06/16/2009 09:33:01          BUFFER     SORT                                        57     31     2     806,976,583,788     50,716     
         06/16/2009 09:33:01          INDEX     FAST FULL SCAN          GEO2     TLAND_COUNTY_FK_I          NON-UNIQUE     ANALYZED          58     57     1     11     50,716      -------------------------------------------------------------
    Edited by: Krithi on 16-Jun-2009 02:47

  • Query is very slow

    Dear All,
    when I run the below query, it takes around 1 to 2 minutes.
    What exact improvement can be made to increase the speed of queries on this table?
    SELECT count(*),j.event_year
    FROM PRC_EVENTS J
    WHERE J.EVENT_TYPE_ID = 63424
    AND   J.E1 = '3'
    and   j.event_date between to_date('01-01-2011','dd-mm-rrrr') and to_date('31-12-2011','dd-mm-rrrr')
    group by j.event_year;I got Result data as below in 1 or 2 minutes.....
    TOTAL_ROWS     EVENT_YEAR
    2838     2010
    33     2009
    6     2007
    39153     2011
    2     2008explain plan for this query is
    SQL> SELECT *
      2  FROM   TABLE(DBMS_XPLAN.DISPLAY);
    PLAN_TABLE_OUTPUT
    Plan hash value: 3649959670
    | Id  | Operation                    | Name             | Rows  | Bytes | Cost (
    |   0 | SELECT STATEMENT             |                  |    16 |   320 | 10546
    |   1 |  HASH GROUP BY               |                  |    16 |   320 | 10546
    |*  2 |   TABLE ACCESS BY INDEX ROWID| PRC_EVENTS       |  3299 | 65980 | 10545
    |*  3 |    INDEX SKIP SCAN           | PRC_EVENTS_IDX27 | 17006 |       |  2404
    Predicate Information (identified by operation id):
       2 - filter("JUDG"."E1"='3')
       3 - access("JUDG"."EVENT_TYPE_ID"=63424 AND "JUDG"."EVENT_DATE">=TO_DATE('201
                  00:00:00', 'yyyy-mm-dd hh24:mi:ss') AND "JUDG"."EVENT_DATE"<=TO_DA
                  00:00:00', 'yyyy-mm-dd hh24:mi:ss'))
           filter("JUDG"."EVENT_DATE">=TO_DATE('2011-01-01 00:00:00', 'yyyy-mm-dd
                  hh24:mi:ss') AND "JUDG"."EVENT_DATE"<=TO_DATE('2011-12-31 00:00:00
    PLAN_TABLE_OUTPUT
                  hh24:mi:ss'))
    21 rows selectedThe complete structure of prc_events table is as below (showing its indexes, tablespaces,triggers and all its related objects)
    CREATE TABLE moj.prc_events
      ID                         NUMBER             NOT NULL,
      server_id                  NUMBER(6)          NOT NULL,
      parent_id                  NUMBER,
      event_type_id              NUMBER             NOT NULL,
      event_year                 NUMBER(4),
      event_no                   NUMBER(8),
      event_date                 DATE               NOT NULL,
      hijra_date                 VARCHAR2(50 BYTE),
      security_level_lkp         NUMBER,
      subject                    VARCHAR2(4000 BYTE) NOT NULL,
      site_id                    NUMBER             NOT NULL,
      dn_site_type_id            NUMBER             NOT NULL,
      wrksec_id_created_by       NUMBER             NOT NULL,
      remarks                    VARCHAR2(1000 BYTE),
      signed_onbehalf_prefix     VARCHAR2(80 BYTE),
      signed_by_prefix           VARCHAR2(80 BYTE),
      signed_position_desc       VARCHAR2(240 BYTE),
      signed_by_id               NUMBER,
      signed_onbehalf_by_id      NUMBER,
      signed_position_id         NUMBER,
      certify_date               DATE,
      certify_user               VARCHAR2(30 BYTE),
      execution_date             DATE,
      execution_user             VARCHAR2(30 BYTE),
      eligibility_check_flag     VARCHAR2(1 BYTE)   NOT NULL,
      eligibility_executed_flag  VARCHAR2(1 BYTE)   NOT NULL,
      flex_ref_no                NUMBER,
      attachment_link_no         NUMBER,
      audit_trail_no             NUMBER,
      created_by                 VARCHAR2(30 BYTE)  NOT NULL,
      creation_date              DATE               NOT NULL,
      last_updated_by            VARCHAR2(30 BYTE)  NOT NULL,
      last_update_date           DATE               NOT NULL,
      e1                         VARCHAR2(255 BYTE),
      e2                         VARCHAR2(255 BYTE),
      e3                         VARCHAR2(255 BYTE),
      e4                         VARCHAR2(255 BYTE),
      e5                         VARCHAR2(255 BYTE),
      e6                         VARCHAR2(255 BYTE),
      e7                         VARCHAR2(255 BYTE),
      e8                         VARCHAR2(255 BYTE),
      e9                         VARCHAR2(255 BYTE),
      e10                        VARCHAR2(255 BYTE),
      e11                        VARCHAR2(255 BYTE),
      e12                        VARCHAR2(255 BYTE),
      e13                        VARCHAR2(255 BYTE),
      e14                        VARCHAR2(255 BYTE),
      e15                        VARCHAR2(255 BYTE),
      event_status_lkp           NUMBER,
      e16                        VARCHAR2(255 BYTE),
      e17                        VARCHAR2(255 BYTE),
      e18                        VARCHAR2(255 BYTE),
      e19                        VARCHAR2(255 BYTE),
      e20                        VARCHAR2(255 BYTE),
      e21                        VARCHAR2(255 BYTE),
      e22                        VARCHAR2(255 BYTE),
      e23                        VARCHAR2(255 BYTE),
      e24                        VARCHAR2(255 BYTE),
      e25                        VARCHAR2(255 BYTE),
      executable_trans_flag      VARCHAR2(1 BYTE)   NOT NULL,
      record_status_lkp          NUMBER,
      parent_type_id             NUMBER,
      nd_parent_id               NUMBER,
      dn_event_type_code         VARCHAR2(30 BYTE),
      status_date                DATE,
      long_e1                    VARCHAR2(4000 BYTE),
      long_e2                    VARCHAR2(4000 BYTE),
      long_e3                    VARCHAR2(4000 BYTE),
      dn_owner_party_person_id   NUMBER,
      e26                        VARCHAR2(255 BYTE),
      e27                        VARCHAR2(255 BYTE),
      e28                        VARCHAR2(255 BYTE),
      e29                        VARCHAR2(255 BYTE),
      e30                        VARCHAR2(255 BYTE),
      dn_business_class_lkp      NUMBER             NOT NULL,
      dn_event_class_lkp         NUMBER             NOT NULL,
      security_class_lkp         NUMBER             NOT NULL,
      site_no                    NUMBER(4)          NOT NULL,
      long_e4                    VARCHAR2(4000 BYTE),
      long_e5                    VARCHAR2(4000 BYTE),
      long_e6                    VARCHAR2(4000 BYTE),
      long_e7                    VARCHAR2(4000 BYTE),
      long_e8                    VARCHAR2(4000 BYTE),
      web_request_id             NUMBER,
      attached_topic_id          NUMBER,
      adult_flag                 VARCHAR2(1 BYTE),
      dn_location_id             NUMBER,
      dn_loc_staff_id            NUMBER,
      dn_receive_date            DATE,
      receive_flag               VARCHAR2(1 BYTE),
      ll_parent_id               NUMBER,
      ll_object_id               NUMBER,
      io_type                    NUMBER(2),
      io_id                      NUMBER(12),
      io_out_seq                 NUMBER,
      file_name                  VARCHAR2(256 BYTE),
      send_police_org_unit_id    NUMBER,
      io_timestamp               DATE,
      inves_no                   NUMBER,
      inves_year                 NUMBER,
      event_no_sno               NUMBER,
      prc_unit_id                NUMBER,
      document_flag              VARCHAR2(2 BYTE),
      copy_serial                NUMBER,
      machine_name               VARCHAR2(255 BYTE),
      hearing_date               DATE
    TABLESPACE ts16k_data
    PCTUSED    0
    PCTFREE    10
    INITRANS   1
    MAXTRANS   255
    STORAGE    (
                INITIAL          1414 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    LOGGING
    NOCOMPRESS
    NOCACHE
    NOPARALLEL
    MONITORING;
    CREATE INDEX moj.dn_location_id_idx ON moj.prc_events
    (dn_location_id)
    LOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          47 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.dn_loc_staff_id_idx ON moj.prc_events
    (dn_loc_staff_id)
    LOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          21 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.e1_indx ON moj.prc_events
    (e1)
    LOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          20 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.e4_indx ON moj.prc_events
    (e4)
    NOLOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          18 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.env_server_id_i ON moj.prc_events
    (server_id)
    NOLOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          49 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.env_wrksec_i ON moj.prc_events
    (wrksec_id_created_by)
    NOLOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          51 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.event_no_sno_i ON moj.prc_events
    (event_no_sno)
    LOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          128 k
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.event_status_i ON moj.prc_events
    (event_status_lkp)
    LOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          11 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.evn_date ON moj.prc_events
    (event_date)
    NOLOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          72 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.evn_date_year_no_idx ON moj.prc_events
    (event_date, event_year, event_no)
    LOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          89 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.evn_evn_typ_i ON moj.prc_events
    (event_type_id)
    NOLOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          56 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.evn_nd_parent_fk_i ON moj.prc_events
    (nd_parent_id)
    NOLOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          17 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.evn_parent_appcmp_fk_i ON moj.prc_events
    (parent_type_id)
    NOLOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          42 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE UNIQUE INDEX moj.evn_pk_i ON moj.prc_events
    (ID)
    NOLOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          57 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.evn_prnt_i ON moj.prc_events
    (parent_id)
    NOLOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          41 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.evn_prt_prs_i ON moj.prc_events
    (dn_owner_party_person_id)
    NOLOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          14 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.evn_site_i ON moj.prc_events
    (site_id)
    NOLOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          49 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.evnt_sngdbyid_indx ON moj.prc_events
    (signed_by_id)
    LOGGING
    TABLESPACE moj_data
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          21600 k
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.evnt_sngonhkbyid_indx ON moj.prc_events
    (signed_onbehalf_by_id)
    LOGGING
    TABLESPACE moj_data
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          864 k
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.evn_year_no_i ON moj.prc_events
    (event_year, event_no)
    LOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          58 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.i1 ON moj.prc_events
    (dn_event_type_code)
    NOLOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          75 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.i2 ON moj.prc_events
    (security_class_lkp)
    LOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          53 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.ix1 ON moj.prc_events
    (event_type_id, e5, event_date, event_year)
    LOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          104 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL
    COMPRESS 2;
    CREATE INDEX moj.ix2 ON moj.prc_events
    (e4, dn_event_type_code)
    LOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          72 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL
    COMPRESS 1;
    CREATE INDEX moj.ix6 ON moj.prc_events
    (event_type_id, event_year, event_no)
    LOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          53 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL
    COMPRESS 2;
    CREATE INDEX moj.prc_event_idx1 ON moj.prc_events
    (e25, event_type_id)
    LOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          72 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.prc_event_idx10 ON moj.prc_events
    (event_type_id, security_class_lkp, event_date)
    LOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          122 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.prc_event_idx11 ON moj.prc_events
    (e4, dn_event_type_code, e5)
    LOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          108 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.prc_event_idx12 ON moj.prc_events
    (event_no, event_year)
    LOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          82 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.prc_event_idx13 ON moj.prc_events
    (subject)
    LOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          128 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.prc_event_idx14 ON moj.prc_events
    (e13, event_type_id, long_e1)
    LOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          190 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.prc_event_idx15 ON moj.prc_events
    (event_type_id, ID)
    LOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          112 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.prc_event_idx16 ON moj.prc_events
    (dn_event_class_lkp)
    LOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          56 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.prc_event_idx17 ON moj.prc_events
    (e26, event_type_id)
    LOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          80 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.prc_event_idx18 ON moj.prc_events
    (e16, event_type_id)
    LOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          72 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.prc_event_idx19 ON moj.prc_events
    (created_by)
    LOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          76 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.prc_event_idx2 ON moj.prc_events
    (e25, event_type_id, e26)
    LOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          89 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.prc_event_idx20 ON moj.prc_events
    (event_type_id, security_class_lkp, TO_NUMBER(TO_CHAR("EVENT_YEAR")))
    LOGGING
    TABLESPACE indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          64 k
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.prc_event_idx21 ON moj.prc_events
    (dn_owner_party_person_id, event_status_lkp, event_type_id)
    LOGGING
    TABLESPACE indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          64 k
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.prc_event_idx22 ON moj.prc_events
    (event_type_id, prc_unit_id, e5, event_date)
    LOGGING
    TABLESPACE indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          64 k
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.prc_event_idx23 ON moj.prc_events
    (event_type_id, e5)
    LOGGING
    TABLESPACE indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          64 k
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.prc_event_idx24 ON moj.prc_events
    (event_type_id, security_class_lkp, e5)
    LOGGING
    TABLESPACE indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          64 k
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.prc_event_idx25 ON moj.prc_events
    (ID, event_year)
    LOGGING
    TABLESPACE indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          64 k
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.prc_event_idx3 ON moj.prc_events
    (event_type_id, parent_id)
    LOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          80 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.prc_event_idx4 ON moj.prc_events
    (event_type_id, prc_unit_id, event_date)
    LOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          100 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.prc_event_idx5 ON moj.prc_events
    (status_date, event_type_id)
    LOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          91 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.prc_event_idx6 ON moj.prc_events
    (e4, event_type_id)
    LOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          81 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.prc_event_idx7 ON moj.prc_events
    (e15, event_type_id, e18)
    LOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          88 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.prc_event_idx8 ON moj.prc_events
    (e15, event_type_id, e18, e12)
    LOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          94 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.prc_event_idx9 ON moj.prc_events
    (event_no, dn_event_type_code, event_year, e5, e4)
    LOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          136 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.prc_event_io_timestamp_idx ON moj.prc_events
    (io_timestamp)
    LOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          10 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.prc_events_e5_i ON moj.prc_events
    (e5)
    NOLOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          28 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.prc_events_idx27 ON moj.prc_events
    (event_type_id, event_status_lkp, event_date)
    LOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          64 k
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.prc_unit_id_indx ON moj.prc_events
    (prc_unit_id)
    NOLOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          53 m
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    CREATE INDEX moj.signed_position_idx ON moj.prc_events
    (signed_position_id)
    LOGGING
    TABLESPACE ts16k_indx
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          64 k
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    ALTER TABLE moj.prc_events ADD (
      CONSTRAINT evn_evn_fk
    FOREIGN KEY (parent_id)
    REFERENCES moj.prc_events (ID),
      CONSTRAINT evn_evn_ndirect_prnt_fk
    FOREIGN KEY (nd_parent_id)
    REFERENCES moj.prc_events (ID),
      CONSTRAINT evn_org_unt_fk
    FOREIGN KEY (site_id)
    REFERENCES moj.env_organization_units (ID),
      CONSTRAINT evn_parent_typ_appcmp_fk
    FOREIGN KEY (parent_type_id)
    REFERENCES base_2000.bsh_application_components (ID),
      CONSTRAINT evn_prt_prs_fk
    FOREIGN KEY (dn_owner_party_person_id)
    REFERENCES moj.env_persons_table (ID),
      CONSTRAINT evn_signed_fk
    FOREIGN KEY (signed_by_id)
    REFERENCES moj.env_persons_table (ID),
      CONSTRAINT evn_signed_onbehalf_fk
    FOREIGN KEY (signed_onbehalf_by_id)
    REFERENCES moj.env_persons_table (ID),
      CONSTRAINT evn_signed_pos_fk
    FOREIGN KEY (signed_position_id)
    REFERENCES moj.env_positions (ID),
      CONSTRAINT evn_typ_appcmp_fk
    FOREIGN KEY (event_type_id)
    REFERENCES base_2000.bsh_application_components (ID));
    GRANT DELETE, INSERT, SELECT, UPDATE ON moj.prc_events TO base_2000_role;
    GRANT DELETE, INSERT, SELECT, UPDATE ON moj.prc_events TO moj_role;Please note that this table is having around 8 million rows and many other queries are slow on this table especially in case of self joins. Further all transactions are saving in this table and also the child transactions and child of the child transactions therefore normally we have to select this table mutiple times in the FROM CLAUSE LIKE

    887419 wrote:
    Yes there are dozens of indexes. I also don't like this table structure, no normalization. Actually this one table should be 10 are more tables but unfortunately, what I can do now because a big application is based on this ugly design.You could normalise this table and put a view in place to recreate the table structure as it stands now, that way you wouldn't break the application from a query point of view. You could also add INSTEAD OF triggers to allow inserts, updates and deletes and redirect them to the new normalised structures.
    >
    Will table partitioning will work for this table.It might do, or it might make things worse. You need to identify a key that is used in all or the vast majority of queries to partition by. Event date might be one, but then again it might not. Another could be event type id, or a category of some type, but if it's only used in a handful of queries you run the risk of slowing all the other queries down to speed your one up.
    user6806750 already mentioned that you could create a new index just to service your query
    maybe something like
    CREATE INDEX xyz on PRC_EVENTS
    (   event_type_id,
        e1,
        event_date,
        event_year
    /Have you looked at index monitoring to see which of these indexes is actually being used? You've got lots of indexes on individual columns and it might be that you can combine quite a number of them into composite indexes that can serve more than one query.
    HTH
    David

Maybe you are looking for

  • Retenção de imposto qdo total da nota acima de 5.000,01, nao retem linha

    Gostaria de ajuda, O meu cliente é uma empresa de serviços, faz os pedidos de vendas , com varios itens de linha e depois faz a nota fiscal de saida selecionando os itens que será faturado, as configurações de retençoes estar de acordo com o valor ex

  • Print headings using RSBTCHH0 on ALV grids

    Most reports I have developed use the list processing event top-of-page to print headings for the report listing by calling standard SAP subroutine BATCH-HEADING in program RSBTCHH0 when structure BHDGD has been populated. Field BHDGD-LINES contains

  • Calendar doesn't work for March 2014

    I am trying to set a recurring event for March 27, 28, 29, from 10 am to 6 pm. March 27 is ok. March 28 only goes to 4 pm. March 29 goes to 6 pm. This is in month view. In week view, march 27 is set for 10-6. But then there is another march 27 from 1

  • Template lost CSS?

    Actually there are two problems that would seem to be related in some way on this site. The first is that when putting a file, I get a dialog box saying that a file has been altered on the remote server and will be overwritten. The box appears on eve

  • Configuring Virus Scan Service for KM in EP7.0 18

    Dear gurus, I did virus scan configurations in ep7.0 18 but I couldn't do the configurations in KM. Is there a blog or document? All the blogs and documents are about Configuring Virus Scan Service for KM in EP 6.0. Best regards Tolga