Query Tunning of Sql performance

Hello

I have A table with size tables plus 120,000002 million are size 2 million on the Table B and less than 1 million on table C.

I had created the Partition and parallel degree 4 on the table Created A. table B with parallel degree 2 and created table C with NOPARALLEL.

My query is using above tables with joins and insertion in table D use INDICATOR / * + APPEND NOLOGGING * /.
I ran the command explain on the above criteria, the cost is showing 20767.

More later created the tables A, B and C with NOPARALLEL. Applied the TIP on Table D / * + APPEND NOLOGGING * /.
and applied als HINT / * + PARALLEL(A, 4) select PARALLEL(B C, 2) on a query that uses to insert in table D.


My question, which advised on the creation of PARALLEL degree at the level of the table or query:


(a) create table with parallel (level 4)

(b) applying HINT / * + PARALLEL (TABLE A, 4) * / at the level of the query

Kind regards
Prakash

957901 wrote:
Hello

I have A table with size tables plus 120,000002 million are size 2 million on the Table B and less than 1 million on table C.

I had created the Partition and parallel degree 4 on the table Created A. table B with parallel degree 2 and created table C with NOPARALLEL.

My query is using above tables with joins and insertion in table D use INDICATOR / * + APPEND NOLOGGING * /.
I ran the command explain on the above criteria, the cost is showing 20767.

The cost is meaningless out of context.

More later created the tables A, B and C with NOPARALLEL. Applied the TIP on Table D / * + APPEND NOLOGGING * /.
and applied als HINT / * + PARALLEL(A, 4) select PARALLEL(B C, 2) on a query that uses to insert in table D.

My question, which advised on the creation of PARALLEL degree at the level of the table or query:

(a) create table with parallel (level 4)

(b) applying HINT / * + PARALLEL (TABLE A, 4) * / at the level of the query

According to what works best for you to reach.

Which is another way of saying that you have not provided enough information for anyone here to take an informed decision or a suggestion for you.

{message: id = 9360002}

For performance issues/tuning queries, read two threads related to this FAQ: {message identifier: = 9360003}

Tags: Database

Similar Questions

  • How to tune my sql?

    Hello

    Could you please tell me how to tune my sql. I have to pay about 100 queries sql (sent by developers) to improve performance. All the links would be useful.

    Version: 10.2.0.1

    User: SYS

    Thank you.

    user_name => 'USER1',

    SY.

  • upgrade 9i Sql performance problems, 10 g

    I've heard several times sql performance problem if db upgrade, what is his fix, this problem SQLs appear in ADDM report with Advisor tunning/access sql to run & its suggestions bugs?

    PL see MOS Doc 466181.1 (10 g companion Upgrade) - this topic is covered in this document

    HTH
    Srini

  • You should know about optimizing SQL performance

    Hi gurus

    I want to know/learn some SQL performance settings, can you please guide me how to I achieve this? Thanks in advance

    Shuumail wrote:

    Can thanks for the reply, you offer me any specific book in your mentioned link?

    The subject itself is not my strong suite, but here are some observations:

    I recently bought the book of Kevin Meade. It is self-published and self published, is not as polished as a lot, but the content seems to be very good.  It establishes a methodical approach with a solid knowledge of the subject.

    Over the years, I've become less enamored of what whether by Burleson.  I was a little surprised to see that one of the books was written by him and Tim Hall.  I do not rely on the website of Mr. Hall for a bunch of stuff 'how to set up'.  On the other hand, if I see a google search show site of Burleson, I usually just pass.

    Whatever it is published by Oracle Press will probably be as solid than anything either, although not totally without error (no book is).  Rich Niemiec is unquestionably one of the top experts on the workings of the oracle, so I expect his book to be very authoritarian.

    I've never been disappointed in a book published by O'Reilly.  They are easy readings and so probably would make a good book "start here."

  • SQL query (or pl / sql) show this week activities

    I need your friends to help to create the sql query (or pl / sql) show of this week's activities, my table is called activity and it has a date field (contains the date of the creation of the application)

    depends on what you describe as 'this week '...

    you could do something like

    WHERE your_date_field > = trunc(sysdate,'IW') AND your_date_field< trunc(sysdate="" +="">

    which would give you anything from Monday to Sunday from the current week

    HTH

  • Need a tool to investigate SQL performance

    If anyone can share a tool to study the SQL performance?

    Hello

    I don't know if this is a good place but you can opt for Quest Toad, which is one of the most common SQL configuration tool.  However, if you are interesting in SQL performance specifically to your DB, then you can consider SQL tuning packs that come with DB Oracle enterprise edition (careful if you use the standard edition).

    In addition, Oracle has a very nice set of scripts allow you to download... but you must have an account to the Oracle support:

    SQL Tuning-health check Script (SQLHC) (Doc ID 1366133.1)

  • SQL performance monitor

    Hello..

    I'm new to sql performance monitor and I need help...

    When I try to create a sql tuning set it asks for a schema to create the tuning series.

    1. what should I use for this?
    2. a particular schema will contain all the sql statements required by the database?
    3.i have multiple schemas in the database... do I do to get all the sql statements for the performance of the database?


    Thank you

    djgeo.

    Hello
    You can select a user database (no application) for the creation of sets of tunng sql

    Salman

  • Rewrite the static query in dynamic SQL

    Can someone please help me write a dynamic query in pl/sql to SQL next?

    It's the game ('25', ' 04 "). the number of list might be n.
    The column_type varies from(1..6) and
    the from(1..6) of column_amt1 lines

     SELECT t.claim_no, t.cert_no, t.rec_code,
     (NVL(decode(t.column_type1,'25',NVL (t.column_amt1, 0)),0)+
        NVL(decode(t.column_type1,'04',NVL(t.column_amt1, 0)),0 )
      )  
      +
       (NVL(decode(t.column_type2,'25',NVL (t.column_amt2, 0)),0)+
        NVL(decode(t.column_type2,'04',NVL(t.column_amt2, 0)),0 )
       ) 
      +
       (NVL(decode(t.column_type3,'25',NVL (t.column_amt3, 0)),0)+
        NVL(decode(t.column_type3,'04',NVL(t.column_amt3, 0)),0 )
       ) 
      +
       (NVL(decode(t.column_type4,'25',NVL (t.column_amt4, 0)),0)+  
         NVL(decode(t.column_type4,'04',NVL(t.column_amt4, 0)),0 )
        ) 
      +
         (NVL(decode(t.column_type5,'25',NVL (t.column_amt5, 0)),0)+  
          NVL(decode(t.column_type5,'04',NVL(t.column_amt5, 0)),0 )
          ) 
      +
          (NVL(decode(t.column_type6,'25',NVL (t.column_amt6, 0)),0)+  
           NVL(decode(t.column_type6,'04',NVL(t.column_amt6, 0)),0 )) amt from test_detail t;
       
    Thanks in advance
    Hena

    But in fact, you should not dynamic SQL at all. What you could do is create a SQL type and use MEMBER OF:

    SQL> CREATE OR REPLACE
      2    TYPE test_detail_type_tbl
      3      AS
      4        TABLE OF varchar2(2)
      5  /
    
    Type created.
    
    SQL> select  case_id,
      2          item,
      3          code,
      4          case
      5            when type1 member of test_detail_type_tbl('25','04') then nvl(amt1,0)
      6            else 0
      7          end +
      8          case
      9            when type2 member of test_detail_type_tbl('25','04') then nvl(amt2,0)
     10            else 0
     11          end +
     12          case
     13            when type3 member of test_detail_type_tbl('25','04') then nvl(amt3,0)
     14            else 0
     15          end +
     16          case
     17            when type4 member of test_detail_type_tbl('25','04') then nvl(amt4,0)
     18            else 0
     19          end +
     20          case
     21            when type5 member of test_detail_type_tbl('25','04') then nvl(amt5,0)
     22            else 0
     23          end +
     24          case
     25            when type6 member of test_detail_type_tbl('25','04') then nvl(amt6,0)
     26            else 0
     27          end copay
     28    from  test_detail
     29  /
    
    CASE_ID    ITEM      CO      COPAY
    ---------- --------- -- ----------
    EML3371015 133761570 10        355
    EML3371015 133761570 10         20
    EML3371015 133761570 10          5
    EMC6369600 140328551 10         54
    EMH6353995 140328551 11      26.04
    
    SQL> select  case_id,
      2          item,
      3          code,
      4          case
      5            when type1 member of test_detail_type_tbl('25') then nvl(amt1,0)
      6            else 0
      7          end +
      8          case
      9            when type2 member of test_detail_type_tbl('25') then nvl(amt2,0)
     10            else 0
     11          end +
     12          case
     13            when type3 member of test_detail_type_tbl('25') then nvl(amt3,0)
     14            else 0
     15          end +
     16          case
     17            when type4 member of test_detail_type_tbl('25') then nvl(amt4,0)
     18            else 0
     19          end +
     20          case
     21            when type5 member of test_detail_type_tbl('25') then nvl(amt5,0)
     22            else 0
     23          end +
     24          case
     25            when type6 member of test_detail_type_tbl('25') then nvl(amt6,0)
     26            else 0
     27          end copay
     28    from  test_detail
     29  /
    
    CASE_ID    ITEM      CO      COPAY
    ---------- --------- -- ----------
    EML3371015 133761570 10        300
    EML3371015 133761570 10         20
    EML3371015 133761570 10          5
    EMC6369600 140328551 10          0
    EMH6353995 140328551 11       5.52
    
    SQL> 
    

    SY.

  • Need a Suggestion tune the SQL query

    Hello


    There is a view that is created that takes 17 seconds to run the query, when I split the query and run each query prend.15 seconds to run. Below the query I need to improve the performance of the code if you need your suggestion please order to tweek so this time take for execution to become less

    SELECT "Parature'"Source. "
    NULL 'retailer ',.
    reseller_name "reseller."
    NULL city "reseller."
    NULL state "reseller."
    A.Country "dealer Country."
    DECODE (a.state, "ACPA", "ACPA", 'EMEA', 'EMEA', NULL, 'Unknown', 'US') "Dealer Theater",
    NULL "Customer Name,"
    NO city 'customer ',.
    'Client state', NULL
    NULL 'country of the customer. "
    NULL "customer Theater."
    NULL "sales book Date."
    NULL "Ship Date."
    c.sales_order_number 'Sales Order Number',
    C.Po_Number "Number"
    controller_model_number_1 "product name."
    TRIM (UPPER (serial_number_1)) 'product serial number.
    c.contract_id "Contract ID",
    product_name 'name of support. "
    To_date (c.contract_purchase_date) "Start Date"
    To_date (c.contract_expiration_date) 'Expiry Date',
    NULL "header Status."
    NULL "status of line."
    NULL 'line Type. "
    NULL "reason for termination of employment."
    NULL 'location_id. "
    NULL 'Product_id '.
    Of edb_assets c,.
    edb_accounts one
    WHERE controller_model_number_1! = 'NULL '.
    AND Serial_Number_1! = 'NULL '.
    AND C.Amid = A.Amid (+)

    UNION
    SELECT "Parature'"Source. "
    NULL 'retailer ',.
    reseller_name "reseller."
    NULL city "reseller."
    NULL state "reseller."
    A.Country "dealer Country."
    DECODE (a.state, "ACPA", "ACPA", 'EMEA', 'EMEA', NULL, 'Unknown', 'US') "Dealer Theater",
    NULL "Customer Name,"
    NO city 'customer ',.
    'Client state', NULL
    NULL 'country of the customer. "
    NULL "customer Theater."
    NULL "sales book Date."
    NULL "Ship Date."
    c.sales_order_number 'Sales Order Number',
    C.Po_Number "Number"
    controller_model_number_2 "product name."
    TRIM (UPPER (serial_number_2)) 'product serial number.
    c.contract_id "Contract ID",
    product_name 'name of support. "
    To_date (c.contract_purchase_date) "Start Date"
    To_date (c.contract_expiration_date) 'Expiry Date',
    NULL "header Status."
    NULL "status of line."
    NULL 'line Type. "
    NULL "reason for termination of employment."
    NULL 'location_id. "
    NULL 'Product_id '.
    Of edb_assets c,.
    edb_accounts one
    WHERE controller_model_number_2! = 'NULL '.
    AND serial_number_2! = 'NULL '.
    AND C.Amid = A.Amid (+)
    UNION

    SELECT "Parature'"Source. "
    NULL 'retailer ',.
    reseller_name "reseller."
    NULL city "reseller."
    NULL state "reseller."
    A.Country "dealer Country."
    DECODE (a.state, "ACPA", "ACPA", 'EMEA', 'EMEA', NULL, 'Unknown', 'US') "Dealer Theater",
    NULL "Customer Name,"
    NO city 'customer ',.
    'Client state', NULL
    NULL 'country of the customer. "
    NULL "customer Theater."
    NULL "sales book Date."
    NULL "Ship Date."
    c.sales_order_number 'Sales Order Number',
    C.Po_Number "Number"
    controller_model_number_3 "product name."
    TRIM (UPPER (serial_number_3)) 'product serial number.
    c.contract_id "Contract ID",
    product_name 'name of support. "
    To_date (c.contract_purchase_date) "Start Date"
    To_date (c.contract_expiration_date) 'Expiry Date',
    NULL "header Status."
    NULL "status of line."
    NULL 'line Type. "
    NULL "reason for termination of employment."
    NULL 'location_id. "
    NULL 'Product_id '.
    Of edb_assets c,.
    edb_accounts one
    WHERE controller_model_number_3! = 'NULL '.
    AND serial_number_3! = 'NULL '.
    AND C.Amid = A.Amid (+)

    UNION
    SELECT "Parature'"Source. "
    NULL 'retailer ',.
    reseller_name "reseller."
    NULL city "reseller."
    NULL state "reseller."
    A.Country "dealer Country."
    DECODE (a.state, "ACPA", "ACPA", 'EMEA', 'EMEA', NULL, 'Unknown', 'US') "Dealer Theater",
    NULL "Customer Name,"
    NO city 'customer ',.
    'Client state', NULL
    NULL 'country of the customer. "
    NULL "customer Theater."
    NULL "sales book Date."
    NULL "Ship Date."
    c.sales_order_number 'Sales Order Number',
    C.Po_Number "Number"
    controller_model_number_4 "product name."
    TRIM (UPPER (serial_number_4)) 'product serial number.
    c.contract_id "Contract ID",
    product_name 'name of support. "
    To_date (c.contract_purchase_date) "Start Date"
    To_date (c.contract_expiration_date) 'Expiry Date',
    NULL "header Status."
    NULL "status of line."
    NULL 'line Type. "
    NULL "reason for termination of employment."
    NULL 'location_id. "
    NULL 'Product_id '.
    Of edb_assets c,.
    edb_accounts one
    WHERE controller_model_number_4! = 'NULL '.
    AND serial_number_4! = 'NULL '.
    AND C.Amid = A.Amid (+)

    UNION
    SELECT "Parature'"Source. "
    NULL 'retailer ',.
    reseller_name "reseller."
    NULL city "reseller."
    NULL state "reseller."
    A.Country "dealer Country."
    DECODE (a.state, "ACPA", "ACPA", 'EMEA', 'EMEA', NULL, 'Unknown', 'US') "Dealer Theater",
    NULL "Customer Name,"
    NO city 'customer ',.
    'Client state', NULL
    NULL 'country of the customer. "
    NULL "customer Theater."
    NULL "sales book Date."
    NULL "Ship Date."
    c.sales_order_number 'Sales Order Number',
    C.Po_Number "Number"
    controller_model_number_5 "product name."
    TRIM (UPPER (serial_number_5)) 'product serial number.
    c.contract_id "Contract ID",
    product_name 'name of support. "
    To_date (c.contract_purchase_date) "Start Date"
    To_date (c.contract_expiration_date) 'Expiry Date',
    NULL "header Status."
    NULL "status of line."
    NULL 'line Type. "
    NULL "reason for termination of employment."
    NULL 'location_id. "
    NULL 'Product_id '.
    Of edb_assets c,.
    edb_accounts one
    WHERE controller_model_number_5! = 'NULL '.
    AND serial_number_5! = 'NULL '.
    AND C.Amid = A.Amid (+)
    UNION
    SELECT "Source", "ERP"
    Imv.Bill_To 'retailer ',.
    Imv.Ship_To "dealer."
    Ship_To_City "Dealer City."
    Ship_To_State "State dealer."
    Edb2_Global.Country_Name_Theater (Imv.Ship_To_Country, 'COUNTRY') 'dealer country. "
    Edb2_Global.Country_Name_Theater (Imv.Ship_To_Country, 'THÉÂTRE') 'dealer Theater. "
    Cl.Company_Name "name of the customer."
    Cl.City "customer's city."
    Cl.State "State of the customer."
    Edb2_Global.Country_Name_Theater (cl.) Country, 'COUNTRY') 'country of the customer. "
    Edb2_Global.Country_Name_Theater (cl.) Country, 'THEATER') "customer Theater."
    Imv.So_Booked_Date "Date from the sale of book."
    Imv.Ship_Date "Delivery Date"
    Imv.Order_Number "client order number."
    Imv.Cust_Po_Number "Number"
    Cp.Item_Name "product name."
    Cp.Product_Serial_Number "serial number of product."
    To_char (Imv.contract_number) "Contract ID"
    Imv.Service_Description "name of support."
    Imv.Service_Start_Date "Start Date"
    Imv.Service_End_Date "expiration Date."
    Imv.Header_Status "header Status."
    Imv.Line_Status "status of line."
    Imv.Line_Type 'line Type. "
    Imv.Termination_Reason "reason for termination of employment."
    Cl.Location_Id 'location_id. "
    CP.ID "Product_id".
    Of ib_support_contracts_mv imv.
    customer_products cp,
    customer_locations cl
    WHERE superior (Trim (Imv.Serial_Number)) = Upper (Trim (Cp.Product_Serial_Number (+)))
    AND Cp.Location_Id = Cl.Location_Id (+)
    /


    There is a Union for each request, please suggest how tweek

    Thank you
    Sudhir

    A quick look indicates that first 5 select queries are that even accepting the 2 conditions

    WHERE controller_model_number_1! = 'NULL '.
    AND Serial_Number_1! = 'NULL '.

    Use SEPARATE and Clause OR reduce these 5 queries in one like that

    SELECT DISTINCT
               .....
               ......  
    
      FROM edb_assets       c
          ,edb_accounts     a
    WHERE  C.Amid = A.Amid(+)
      AND  (
              (     controller_model_number_1 != 'NULL'
                AND Serial_Number_1 != 'NULL'
              )
             OR
              (     controller_model_number_2 != 'NULL'
                AND Serial_Number_2 != 'NULL'
              )
             OR
              (     controller_model_number_3 != 'NULL'
                AND Serial_Number_3 != 'NULL'
              )
             OR
              (     controller_model_number_4 != 'NULL'
                AND Serial_Number_4 != 'NULL'
              )
             OR
              (     controller_model_number_5 != 'NULL'
                AND Serial_Number_5 != 'NULL'
              )
    
           )
    

    Concerning
    Arun

    Published by: Arun Kumar Gupta on May 9, 2012 12:10

  • Variable performance on a recursive query/view/CTE SQL - server 2008 R2

    I ask for help on the following problem.

    We use a view with a recursive select in it (see below). On a specific server (Server A) the performance of this view varies a lot. Respons times differ between 100 ms and 30 seconds or even more. We tested the same point of view on a backup of the database on another server (Server B) which results in a stable and good performance. A backup of the database that is installed on a server with no other interaction even results in variable performance. We compared the settings of operating system and the database on server A and Server B. There is no difference.

    We need additional input to resolve this problem. So please help!

    Concerning

    Announcement

    Create view [dbo]. [vwMarketSegmentsAll] as

    WITH MarketSegmentsAll (MSID, MSVersion, MSName, MarketSegmentFK, SegmentCategoryFK, RegionFK, country code, CountryFK, GlobalSegmentFK, MSLevel, MSCode, FirstActiveYear, LastActiveYear, Label, RootMarketSegmentFK, CropSegmentFK, CropFK) AS
    (
    -Definition of anchor member
    SELECT ms.ID, Mrs. Version ms. name, Mrs. MarketSegmentFK, Mrs. SegmentCategoryFK, Mrs. RegionFK, r.CountryCode, r.ID as CountryFK, Mrs. GlobalSegmentFK, 1, MSCode = CAST (ms. GlobalSegmentFK as nvarchar (50)), Mrs. FirstActiveYear, Mrs. LastActiveYear, gs. Label, ms.ID, gs. CropSegmentFK, gs. CropFK
    MarketSegment AS ms
    Join region r on r.id = ms. RegionFK
    Join GlobalSegment GS on gs.id = MS GlobalSegmentFK.
    If not of ms. GlobalSegmentFK is null
    UNION ALL
    -Recursive member definition
    SELECT ms.ID, Mrs. Version ms. name, Mrs. MarketSegmentFK, Mrs. SegmentCategoryFK, Mrs. RegionFK, msc. CountryCode, msc. CountryFK, msc. GlobalSegmentFK, msc. MSLevel + 1, CAST (MSCode + case when Ms..) SegmentCategoryFK is null then "another '-' + CAST (ms. SegmentCategoryFK as nvarchar (3)) end as nvarchar (50)), Mrs. FirstActiveYear, Mrs. LastActiveYear, msc. Label, msc. RootMarketSegmentFK, msc. CropSegmentFK, msc. CropFK
    MarketSegment AS ms
    JOIN MarketSegmentsAll AS msc ON msc. MSID = MarketSegmentFK Ms.
    where Mrs. GlobalSegmentFK is null
    )
    -The statement that executes the CTE
    Select msA.MSLevel,
    msA.MSVersion,
    msA.MSCode,
    msA.MSName,
    msA.MSID,
    msA.MarketSegmentFK,
    msA.SegmentCategoryFK,
    msA.GlobalSegmentFK,
    msA.RegionFK,
    msA.CountryCode,
    msA.CountryFK,
    msA.FirstActiveYear,
    msA.LastActiveYear,
    msA.Label,
    RootMarketSegmentFK =
    CASE
    WHEN msA.MSLevel > 1 THEN msA.RootMarketSegmentFK
    ELSE null
    END,
    MSA. CropSegmentFK,
    MSA. CropFK

    OF MarketSegmentsAll msA

    GO

    This issue is beyond the scope of this site (for consumers) and to be sure, you get the best (and fastest) reply, we have to ask either on Technet (for IT Pro) or MSDN (for developers)
    *
  • Help with sql query / a subquery to perform the COUNT

    Hello everyone,

    Co-worker colleague asked me to post a request here in hopes of getting more support.  Here's the question:

    There are 3 tables associated with this request.  A table of the application, which displays a number of application open for a particular request, an audit table that shows you all employees who worked on this application and one employee who shows you the details of the employee table.  My colleague is trying to understand what, how to see only applications that have been published by a wizard, but not a Manager.  There are a few applications that worked on both, but he won't see this request in its results.

    Here are the tables

    EMP

    ID FULL_NAME
    1234John Doe
    5467Jane Doe
    2345Clark Kent
    5432June Cleaver

    Unfortunately, this table does not have a title column (which was created provider, so we cannot change the internal structure).  My colleague knows who is the Assistant and the Director, then in this case, the first two of the id:

    1234 and 5467 are managers and the other 2 are assistants

    T_APPLICATION

    app_id app_number date_opened app_type
    901854778JANUARY 10, 2014NETWORK
    901954779JANUARY 11, 2014DATABASE
    901055000MARCH 12, 2014MATERIAL

    T_APP_AUDIT

    APP_ID PROCESSED_BY
    90181234
    90182345
    90185432
    90192345
    90195432
    90105432

    So, here is the actual query, I was given: it is actually to check the number of times that each application has been published per person:

    Select a.app_id, c.full_name, count (*) that controls

    t_application a, t_app_audit b, c of the emp

    where a.app_id = b.app_id and b.processed_by = c.id and

    a.app_type in ('NETWORK', "DATABASE")

    and b.processed not in ('1234, ' 5467')

    GROUP OF A.APP_ID, c.full_name;

    IF I won't see 9018 in my results, since at one time it was edited by a Manager (1234).  Unfortunately, this request does not eliminate the app_id 9018, it eliminates only the name of handlers appear in the query.  I hope I've explained this properly, and any help to point us in the right direction is welcomed.  Thanks in advance.

    Select

    a.app_id

    c.full_name

    , count (*) as the controls

    of t_application one

    t_app_audit b

    c of the emp

    where a.app_id = b.app_id

    and b.processed_by = c.id

    and a.app_type in ('NETWORK', "DATABASE")

    and b.app_id by (not in

    Select app_id

    of t_app_audit

    where processed_by in ('1234, ' 5467')

    )

    GROUP OF A.APP_ID, c.full_name;

  • SQLite query processing:-defined SQL error:-it works very well in BB OS6.0 bt not in OS5.0 BB

    Hello

    I'm a newbee in webworks...

    I am trying to use SQlite. I create a table and access the data from it on the same page... it works fine... but when I try to do the same thing in different page it gives the error of SQL batch. Now even once when I click the button to access from this page it works fine.

    I mean that the SQL query does not work in the first time. the second time it works.

    It works great in BB OS6.0 bt not in OS5.0 BB

    What a timing problem in 5.0 or something else...?

    Please let me know the problem. I'm stuck... Help, please!

    Thank you, Joy Gupta

    Hi joygupta,

    It is important to realize that all SQL database api is written to be used asynchronously. This means in general in order to ensure that your code works you must perform your events one after the other. If you look around these forums there are plenty of examples of people making small errors that have been fixed in this way.

    If you need help I'd post your code.

  • Query on v$ sql view

    Hello

    V$ sql inside view we have columns

    1 ELAPSED_TIME - out of time (in microseconds) used by this slider for the analysis, execution and recovery

    2 CPU_TIME - time (in microseconds) CPU used by this slider for the analysis, execution and fetch

    3. OPERATIONS - number of executions that have taken place on this object because it has been brought into the library cache

    1 I knew was that it took these many seconds to run the particular query.

    My request is that the ELAPSED_TIME, the CPU_TIME are for single execution or any performance of this query?

    If these are to all executions, so I guess this time of execution by executing unique will be: = ELAPSED_TIME/EXECUTIONS and CPU times a single run will be: = CPU_TIME / EXECUTIONS.

    Right?

    Is there an another way as well as to find the running time by a single execution of a SQL?

    Thank you
    oratest

    The column elapsed_time and cpu_time are cumulative so yes you have to divide by the executions of a particular cursor to get averages for IT... with regard to the time of a particular execution of a cursor - what are you doing here? Y at - it a particular session is running slowly? If so you could follow that execution of the request for individual values.

    If you try to get more accurate averages for particular times try to search in the AWR data - dba_hist_sqlstat, containing the image from each AWR snapshot, so you can work the deltas, then the average elapsed_time at certain times of the day.

    HTH, thank you

    Paul

  • SQL Performance question

    Hello

    The following query performs badly when the predicate

    AND (v_actionFlag IS NULL or ACTION_CODE = v_actionFlag)

    is present. In all executions of the query v_actionFlag will be NULL. In addition, because of the plan when the predicate is included, the returned results are incorrect. We seek to treat rows with the lowest priority. With the included predicate query performs the join, gets 20 lines, sorts, and puts back them rather than getting 20 lines with the lowest priority through the index of QUEUE_TAB0 and return of these.

    The questions I have are-

    -Why the predicate affects the query in this way
    -What is the difference between the HASH JOIN ANTI and HASH JOIN RIGHT ANTI


    We were able to remove this predicate as the functionality it supports has not yet been implemented.



    Background

    Version of DB - 10.2.0.4
    optimizer_features_enable - 10.2.0.4
    optimizer_mode - ALL_ROWS
    Table
    
    - table has approximately 475,000 rows and the statistics are up to date
    
    
    sql> desc queue_tab
     Name                                      Null?    Type
     ----------------------------------------- -------- ----------------------------
     ENTITY_KEY                                NOT NULL NUMBER(12)
     ENTITY_TYPE                               NOT NULL CHAR(1)
     ACTION_CODE                               NOT NULL CHAR(1)
     REPORT_NO                                 NOT NULL NUMBER(12)
     PRIORITY                                  NOT NULL NUMBER(4)
    
    
    
    Indexes
    
    Primary Key (QUEUE_TAB_PK)
    
     ENTITY_KEY                                 
     ENTITY_TYPE                                
     ACTION_CODE                                
     REPORT_NO 
    
    
    Non Unique Index (QUEUE_TAB0)
    
     PRIORITY  
     ENTITY_KEY   
     ENTITY_TYPE  
     ACTION_CODE 
    
    
    
    Cursor
    
    
            SELECT /*+ INDEX_ASC (main QUEUE_TAB0) */
                   REPORT_NO
                 , ENTITY_TYPE
                 , ENTITY_KEY
                 , ACTION_CODE
                 , PRIORITY
              FROM QUEUE_TABV01 main
             WHERE PRIORITY > 1
               AND (v_actionFlag IS NULL OR ACTION_CODE = v_actionFlag )
               AND NOT EXISTS
                   ( SELECT /*+ INDEX_ASC (other QUEUE_TAB_pk) */ 1
                       FROM QUEUE_TABV01 other
                      WHERE main.ENTITY_TYPE = other.ENTITY_TYPE
                        AND main.ENTITY_KEY = other.ENTITY_KEY
                        AND main._ACTION_CODE IN ( constant1, constant2 )
                        AND other.ACTION_CODE IN ( constant3, constant4 ) )
               AND NOT EXISTS
                   ( SELECT 1 FROM QUEUE_TABV01 multi
                      WHERE main.ENTITY_TYPE = multi.ENTITY_TYPE
                        AND main.ENTITY_KEY = multi.ENTITY_KEY
                        AND multi.PRIORITY = 1 )
               AND ROWNUM < rowCount + 1
             ORDER BY PRIORITY, ENTITY_KEY, ENTITY_TYPE,
                      ACTION_CODE;
    
    
                                     
    Plan when predicate "AND (v_actionFlag IS NULL OR ACTION_CODE = v_actionFlag )" is present
    
    
    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       21      5.53       5.40          2     780463          0          20
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total       23      5.53       5.40          2     780463          0          20
    
    Misses in library cache during parse: 0
    Optimizer mode: ALL_ROWS
    Parsing user id: 60     (recursive depth: 1)
    
    Rows     Row Source Operation
    -------  ---------------------------------------------------
         20  SORT ORDER BY (cr=780463 pr=2 pw=0 time=5400939 us)
         20   COUNT STOPKEY (cr=780463 pr=2 pw=0 time=5400872 us)
         20    HASH JOIN ANTI (cr=780463 pr=2 pw=0 time=5400823 us)
     459033     TABLE ACCESS BY INDEX ROWID QUEUE_TAB (cr=780460 pr=2 pw=0 time=4640394 us)
     459033      INDEX RANGE SCAN QUEUE_TAB0 (cr=608323 pr=1 pw=0 time=3263977 us)(object id 68038)
      10529       FILTER  (cr=599795 pr=1 pw=0 time=2573230 us)
      10529        INDEX RANGE SCAN QUEUE_TAB_PK (cr=599795 pr=1 pw=0 time=2187209 us)(object id 68037)
          0     INDEX RANGE SCAN QUEUE_TAB0 (cr=3 pr=0 pw=0 time=34 us)(object id 68038)
    
    
    
    
    Plan when predicate "AND (v_actionFlag IS NULL OR ACTION_CODE = v_actionFlag )" is removed
    
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.02       0.00          0          0          0           0
    Fetch       21      0.05       0.05          0       6035          0          20
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total       23      0.07       0.06          0       6035          0          20
    
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 60     (recursive depth: 1)
    
    Rows     Row Source Operation
    -------  ---------------------------------------------------
         20  SORT ORDER BY (cr=6035 pr=0 pw=0 time=54043 us)
         20   COUNT STOPKEY (cr=6035 pr=0 pw=0 time=962 us)
         20    HASH JOIN RIGHT ANTI (cr=6035 pr=0 pw=0 time=920 us)
          0     INDEX RANGE SCAN QUEUE_TAB0 (cr=3 pr=0 pw=0 time=53 us)(object id 68038)
         20     TABLE ACCESS BY INDEX ROWID QUEUE_TAB (cr=6032 pr=0 pw=0 time=701 us)
         20      INDEX RANGE SCAN QUEUE_TAB0 (cr=6001 pr=0 pw=0 time=533 us)(object id 68038)
         40       FILTER  (cr=199 pr=0 pw=0 time=2048 us)
         40        INDEX RANGE SCAN QUEUE_TAB_PK (cr=199 pr=0 pw=0 time=1975 us)(object id 68037)

    user599445 wrote:
    Hello Justin and Camille,

    Thank you for taking the time to look at it. I changed the query to correctly practice the ROWNUM. I run and traced the query with the predicate IS NULL and without, with each track below. As you both have suggested that the predicate appears to have no impact on the plan does. All feedback is appeciated.

    Mark,

    the obvious problem with the new plan is that no record is filtered by the first NOT EXISTS clause (using anti-join operation), and then for each line an index seek is performed that filters the records only about 14 000. It is the search for index that takes most of the time, gets consistent since he performs about 2 e/s logic by research, in total nearly 1 million.

    The last 456 000 rows are then sorted (top n) and the top 20 are returned.

    A possible problem could be that the optimizer does not switch mode optimization first_rows_N due to the variable binding used in the filter ROWNUM.

    You can try to execute the statement using a literal (ROWNUM< 21)="" instead="" of="" the="" bind="" variable="" to="" see="" if="" it="" changes="">

    I think in this case, it could be much more effective for the QUEUE_TAB0 of the market index in the order requested and perform the two NOT EXISTS clause as activities of recursive filters provided as your ROWNUM predicate is generally rather low.

    Be aware however that is you do not use a "binary" NLS_SORT index parameter can not be used for an operation of NOSORT ORDER BY STOPKEY of CHAR values, so please check your settings NLS (NLS_SESSION_PARAMETERS. PARAMETER = "NLS_SORT") in which case the optimizer will not use the index for sorting. Note that the NLS parameters are customer specific and can theoretically be different for each session / client.

    You can test this by using a query simple top N: SELECT * FROM (SELECT * ACTION_CODE, ENTITY_TYPE, ENTITY_KEY, QUEUE_TAB ORDER OF PRIORITY) WHERE ROWNUM<>

    If it does not use the QUEUE_TAB0 index to stop the sort operation, you might have a problem with the NLS parameters.

    In order to prevent the transformation of the GUESSED you can also try adding a hint NO_UNNEST two subqueries ("SELECT / * + NO_UNNEST * /...") ("in the respective subquery) and you can also try to switch mode FIRST_ROWS (n) using for example the FIRST_ROWS indicator (20) in the body of the request (but which must be done by the ROWNUM predicate).

    Kind regards
    Randolf

    Oracle related blog stuff:
    http://Oracle-Randolf.blogspot.com/

    SQLTools ++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676 /.
    http://sourceforge.NET/projects/SQLT-pp/

  • Using APEX_ITEM in SQL performance issues?

    Hello

    I was wondering if using APEX_ITEM.* in your SQL source for a report would give some performance issues? I expect the report to bring a little more than 3000 documents. When I developed it it was working fine but we had 150 cases or so, but now we have migrated demand during our test the page system will take about 2 minutes to load. Here is my SQL to create the report:

    Select distinct
    initcap (MPa.pa_name) | ' (' || sd. DESIGNATION_CODE | ')' site.
    FRC. REPORT_DESCRIPTION report_category,
    MF. Function FEATURE_DESC
    decode (cmf. SELECTED_FOR_QA, 'Y', 'X', ' N ',' ') QA,.
    () apex_item.select_list_from_query
    21,
    CPF. ASSIGN_TO,
    «Select ss.firstname | "» '' || SS. Surname d, ss. STAFF_NUMBER r
    of snh_staff ss,.
    snh_management_units smu,
    m_pa_snh_area psa
    where ss. MU_UNIT_ID = EMS. UNIT_ID
    and smu. UNIT_ID = psa. UNIT_ID
    and ss. CURRENTLY_EMPLOYED = "Y"
    and psa. SCM_LEAD = "Y"
    and psa. MAIN_AREA = "P"
    and psa.PA_CODE = ' | MPa.pa_code,
    NULL,
    '' YES. ''
    NULL,
    (' ') assign_to,.
    () apex_item.select_list_from_query
    22,
    Decode (to_char (cpf.planned_fieldwork, ' DD/MM /'),)
    30/06 /', 'Q1 ' | TO_CHAR (planned_fieldwork, 'YYYY'),
    30/09 /', 'T2 ' | TO_CHAR (planned_fieldwork, 'YYYY'),
    31/12 /', 'Q3 | TO_CHAR (planned_fieldwork, 'YYYY'),
    31/03 /', 'T4 ' | TO_CHAR (planned_fieldwork-365, "YYYY").
    TO_CHAR (cpf.planned_fieldwork, "YYYY")),
    ' select r d,
    of CM_CYCLE_Q_YEARS') planned_fieldwork,.
    () apex_item.select_list_from_query
    23,
    Decode (to_char (cpf.planned_cmf, ' DD/MM /'),)
    30/06 /', 'Q1 ' | TO_CHAR (planned_cmf, 'YYYY'),
    30/09 /', 'T2 ' | TO_CHAR (planned_cmf, 'YYYY'),
    31/12 /', 'Q3 | TO_CHAR (planned_cmf, 'YYYY'),
    31/03 /', 'T4 ' | TO_CHAR (planned_cmf-365, "YYYY").
    TO_CHAR (cpf.planned_cmf, "YYYY")),
    ' select r d,
    of CM_CYCLE_Q_YEARS') planned_cmf,.
    () apex_item.select_list_from_query
    24,
    CPF.monitoring_method_id,
    "(Select METHOD, MONITORING_METHOD_ID from cm_monitoring_methods where active_flag ="Y"') monitoring_method,
    (apex_item). Text
    25,
    CPF.pre_cycle_comments,
    15,
    255,
    "title =" '. CPF.pre_cycle_comments |' » ',
    'annualPlanningComments '.
    || TO_CHAR (cpf. Comment PLAN_MON_FEATURE_ID)),
    (apex_item). Text
    26,
    TO_CHAR (cpf. CONTRACT_LET, 'MON-DD-YYYY'),
    11,
    (11) contract_let,
    (apex_item). Text
    27,
    TO_CHAR (cpf. CONTRACT_REPORT_PLANNED, 'MON-DD-YYYY'),
    11,
    (11) contract_report,
    (apex_item). Text
    28,
    CPF. ADVISOR_DATA_ENTRY,
    11,
    (11) advisor_entry,
    CMS.complete_percentage | ' ' || status of CMS. Description,
    (apex_item). Text
    29,
    TO_CHAR (cpf. RESULT_SENT_TO_OO, 'MON-DD-YYYY'),
    11,
    (11) result_to_oo,
    CPF. PLAN_MON_FEATURE_ID,
    CMF. MONITORED_FEATURE_ID,
    mpa.PA_CODE,
    MPF. SITE_FEATURE_ID
    of fm_report_category ERS,
    m_feature mf,
    m_pa_features mpf,
    m_protected_area mpa,
    snh_designations sd,
    cm_monitored_features FMC,
    cm_plan_mon_features FCP,
    cm_monitoring_status cms,
    cm_cycles cc,
    msa m_pa_snh_area,
    snh_management_units smu,
    ssa snh_sub_areas
    where frc. REPORT_CATEGORY_ID = mf. REPORT_CATEGORY_ID
    and mf. Feature_code = mpf. FEATURE_CODE
    and mpa.PA_CODE = mpf.PA_CODE
    and mpa. DESIGNATION_ID = sd. DESIGNATION_ID
    and the mpf. SITE_FEATURE_ID = FCM. SITE_FEATURE_ID
    and CME. MONITORED_FEATURE_ID = cpf. MONITORED_FEATURE_ID
    and cms. MONITORING_STATUS_ID = FCM. MONITORING_STATUS_ID
    and cc. CYCLE # = FCM. CYCLE #.
    and msa.PA_CODE = mpa.PA_CODE
    and msa. UNIT_ID = EMS. UNIT_ID
    and msa. SUB_AREA_ID = ass. SUB_AREA_ID
    and cc. CURRENT_CYCLE = 'Y '.
    and msa. MAIN_AREA = 'P '.
    and msa. SCM_LEAD = 'Y '.
    and the mpf. INTEREST_CODE in (1,2,3,9)
    and ((nvl (: P6_REPORTING_CATEGORY, 'TOUT') = 'ALL'))
    and to_char (frc. FCA_FEATURE_CATEGORY_ID) = case nvl (: P6_BROAD_CATEGORY, 'ALL') when "ALL" then to_char (frc. (FCA_FEATURE_CATEGORY_ID) else: P6_BROAD_CATEGORY end)
    or (nvl (: P6_REPORTING_CATEGORY, 'ALL')! = 'ALL')
    and to_char (mf. REPORT_CATEGORY_ID) = case nvl (: P6_REPORTING_CATEGORY, 'ALL') when "ALL" then to_char (mf. REPORT_CATEGORY_ID) else: P6_REPORTING_CATEGORY end))
    and ((nvl (: P6_SNH_SUB_AREA, 'TOUT') = 'ALL'))
    and to_char (msa. UNIT_ID) = case nvl (: P6_SNH_AREA, 'ALL') when "ALL" then to_char (msa. (UNIT_ID) else: P6_SNH_AREA end)
    or (nvl (: P6_SNH_SUB_AREA, 'ALL')! = 'ALL')
    and to_char (msa. SUB_AREA_ID) = case nvl (: P6_SNH_SUB_AREA, 'ALL') when "ALL" then to_char (msa. SUB_AREA_ID) else: P6_SNH_SUB_AREA end))
    and ((nvl (: P6_SITE, 'TOUT')! = 'ALL'))
    and mpa.PA_CODE =: P6_SITE)
    or nvl (: P6_SITE, 'ALL') = 'ALL')

    As you can see I have 9 calls the APEX_ITEM API and when I get out them the works of report that I expect.

    Has anyone else ran into this problem?

    We're currently on APEX: 3.0.1.00.08 and using Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64 bit, Production database.

    Thanks in advance,
    Paul.

    Try to remove all except one of the calls apex_item.select_list_from_query, and then rewrite this one to use subquery factoring. Now compare at the same time for the same query with and without subquery factoring. In addition, 500 lines is a realistic number that you expect someone to change?

Maybe you are looking for