Performance tuning -index on big table on date column

Hi,
I am working on Oracle 10g with Oracle Apps 11i on Sun.
we have a large non-partition table "GL_JE_HEADERS" with 7 million rows.
Now we want to run the query for selecting rows using between clause on date column.
I have created Btree index on the this table.
Now how can I tune the query? Which hint should I use for the query?
Thanks,
rane

Hi Rane,
Now how can I tune the query?Indexes on DATE datatypes are tricky, as the SQL queries must match the index!
For example, an index on ship_date would NOT match a query:
WHERE trunc(ship_date) > trunc(sysdate-7);
WHERE to_char(ship_date,’YYYY-MM-DD’) = ‘2004-01-04’;
You may need to create an function-basd index, so that the DATE reference in your SQL matches the index:
http://www.dba-oracle.com/oracle_tips_index_scan_fbi_sql.htm
To start testing, go into SQL*Plus and "set autotrace on" and run the queries.
Then confirm that your index is being used.
Which hint should I use for the query?Hints are a last resort!
Your query is fully tuned when it fetches the rows you need with a minimum of block touches (logical reads, consistent gets).
See here for details:
http://www.dba-oracle.com/art_sql_tune.htm
Hope this helps . . .
Donald K. Burleson
Oracle Press author
Author of "Oracle Tuning: The Definitive Reference"
http://www.rampant-books.com/book_2005_1_awr_proactive_tuning.htm

Similar Messages

  • ODP OracleCommandBuilder. Updating a table including DATE columns.

    Hi
    I have a problem with the OracleCommandBuilder not creating the correct update commands when I have DATE type columns in the table.
    I have created a test table (called DATETEST) with three columns:
    STRINGCOLUMN     VARCHAR2 10
    DATECOLUMN DATE
    NUMBERCOLUMN     NUMBER
    The STRINGCOLUMN is the primary key.
    Then I created a typed dataset that looks like this:
    STRINGCOLUMN     string
    DATECOLUMN string
    NUMBERCOLUMN     long
    This is the XML schema for the typed dataset:
    <?xml version="1.0" encoding="utf-8" ?>
    <xs:schema id="DateDS" targetNamespace="http://tempuri.org/DateDS.xsd" elementFormDefault="qualified" attributeFormDefault="qualified" xmlns="http://tempuri.org/DateDS.xsd" xmlns:mstns="http://tempuri.org/DateDS.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
         <xs:element name="DateDS" msdata:IsDataSet="true">
              <xs:complexType>
                   <xs:choice maxOccurs="unbounded">
                        <xs:element name="DATETEST">
                             <xs:complexType>
                                  <xs:sequence>
                                       <xs:element name="DATECOLUMN" type="xs:string" minOccurs="0" />
                                       <xs:element name="STRINGCOLUMN" type="xs:string" minOccurs="0" />
                                       <xs:element name="NUMBERCOLUMN" type="xs:long" minOccurs="0" />
                                  </xs:sequence>
                             </xs:complexType>
                        </xs:element>
                   </xs:choice>
              </xs:complexType>
         </xs:element>
    </xs:schema>
    And this is the test code:
    Dim connection As Oracle.DataAccess.Client.OracleConnection
    Dim adapter As New Oracle.DataAccess.Client.OracleDataAdapter()
    Dim dbCommand As New Oracle.DataAccess.Client.OracleCommand()
    Dim sqlstring As String
    Dim data As New DateDS() 'Typed dataset
    Const ConnectionString As String = "User Id=............."
    Try
    'Connect to database
    connection = New OracleConnection(ConnectionString)
    connection.Open()
    'Get data from table DATETEST
    dbCommand.CommandText = "SELECT STRINGCOLUMN, TO_CHAR(DATECOLUMN) AS DATECOLUMN, NUMBERCOLUMN FROM DATETEST"
    dbCommand.Connection = connection
    adapter.SelectCommand = dbCommand
    adapter.Fill(data, "DATETEST")
    'Make changes to dataset
    data.DATETEST(0).DATECOLUMN = Now()
    data.DATETEST(0).NUMBERCOLUMN = data.DATETEST(0).NUMBERCOLUMN + 1
    'Update database
    sqlstring = "SELECT * FROM DATETEST"
    adapter.SelectCommand = New OracleCommand(sqlstring, connection)
    Dim custCB As New Oracle.DataAccess.Client.OracleCommandBuilder()
    custCB.DataAdapter = adapter
    adapter.Update(data, "DATETEST")
    'Disconnect
    connection.Close()
    connection.Dispose()
    Catch exc As Exception
    MessageBox.Show(exc.Message)
    End Try
    Getting the data from the database is not a problem.
    The dataset contains the correct information.
    But updating the database is impossible.
    I get errors like:
    ORA-01861: literal does not match format string
    And if I don't specify a DATE format in the TO_CHAR statement I get this error:
    Concurrency violation: the UpdateCommand affected 0 records.
    I think I've tried everything.
    I've used the OracleGlobalization class, with the SetSessionInfo method.
    I've tried all different types of date conversions to make sure that
    the date format on the database is the same as in the dataset.
    I've tried to change the NLS parameters on the DB server and in the registry on the client.
    I've tried to change the DATECOLUMN type in the typed dataset from string to Oracle.DataAccess.Types.OracleDate
    But it still doesn't work.
    The default date format on the DB 9i server is AMERICAN,(DD-MON-RR).
    A strange thing is that when I instead of using the ODP classes use
    the System.Data.OracleClient and its OracleCommandBuilder
    the code works perfectly without any errors.
    This is the test code that works:
    Dim connection As System.Data.OracleClient.OracleConnection
    Dim adapter As New System.Data.OracleClient.OracleDataAdapter()
    Dim dbCommand As New System.Data.OracleClient.OracleCommand()
    Dim data As New DateDS()
    Dim sqlstring As String
    Const ConnectionString As String = "User Id=......."
    Try
    'Connect to database
    connection = New System.Data.OracleClient.OracleConnection(ConnectionString)
    connection.Open()
    'Get data from table DATETEST
    dbCommand.CommandText = "SELECT STRINGCOLUMN, TO_CHAR(DATECOLUMN,'YYYY-MM-DD HH24:MI:SS') AS DATECOLUMN, NUMBERCOLUMN FROM DATETEST"
    dbCommand.Connection = connection
    adapter.SelectCommand = dbCommand
    adapter.Fill(data, "DATETEST")
    'Make changes to dataset
    data.DATETEST(0).DATECOLUMN = Now()
    data.DATETEST(0).NUMBERCOLUMN = data.DATETEST(0).NUMBERCOLUMN + 1
    'Update database
    sqlstring = "SELECT * FROM DATETEST"
    adapter.SelectCommand = New System.Data.OracleClient.OracleCommand(sqlstring, connection)
    Dim custCB As New System.Data.OracleClient.OracleCommandBuilder()
    custCB.DataAdapter = adapter
    adapter.Update(data, "DATETEST")
    'Disconnect
    connection.Close()
    connection.Dispose()
    Catch exc As Exception
    MessageBox.Show(exc.Message)
    End Try
    My experience until this came up is that the ODP provider is better on everything
    than the microsoft Oracle provider so I don't want to switch unless I have to.
    Could someone that have used the ODP OracleCommandBuilder for updating a table including DATE columns with a typed dataset please give me some tips on how to make this work?
    I would be the happiest man on earth if someone had a solution :-)
    Erik

    Don't convert the dates to strings. Ever.
    The command builder uses the metadata returned from the select command to build the insert/update commands. Using to_char in the query tells ODP that that is a varchar2 column. If you omit the to_char the commandBuilder will know to bind a date parameter in that spot.
    Also in your typed dataset you should change the type from a string to a date.
    David

  • Performance Tuning Query on Large Tables

    Hi All,
    I am new to the forums and have a very specic use case which requires performance tuning, but there are some limitations on what changes I am actualy able to make to the underlying data. Essentially I have two tables which contain what should be identical data, but for reasons of a less than optimal operational nature, the datasets are different in a number of ways.
    Essentially I am querying call record detail data. Table 1 (refered to in my test code as TIME_TEST) is what I want to consider the master data, or the "ultimate truth" if you will. Table one contains the CALLED_NUMBER which is always in a consistent format. It also contains the CALLED_DATE_TIME and DURATION (in seconds).
    Table 2 (TIME_TEST_COMPARE) is a reconciliation table taken from a different source but there is no consistent unique identifiers or PK-FK relations. This table contains a wide array of differing CALLED_NUMBER formats, hugely different to that in the master table. There is also scope that the time stamp may be out by up to 30 seconds, crazy I know, but that's just the way it is and I have no control over the source of this data. Finally the duration (in seconds) can be out by up to 5 seconds +/-.
    I want to create a join returning all of the master data and matching the master table to the reconciliation table on CALLED_NUMBER / CALL_DATE_TIME / DURATION. I have written the query which works from a logi perspective but it performs very badly (master table = 200,000 records, rec table = 6,000,000+ records). I am able to add partitions (currently the tables are partitioned by month of CALL_DATE_TIME) and can also apply indexes. I cannot make any changes at this time to the ETL process loading the data into these tables.
    I paste below the create table and insert scripts to recreate my scenario & the query that I am using. Any practical suggestions for query / table optimisation would be greatly appreciated.
    Kind regards
    Mike
    -------------- NOTE: ALL DATA HAS BEEN DE-SENSITISED
    /* --- CODE TO CREATE AND POPULATE TEST TABLES ---- */
    --CREATE MAIN "TIME_TEST" TABLE: THIS TABLE HOLDS CALLED NUMBERS IN A SPECIFIED/PRE-DEFINED FORMAT
    CREATE TABLE TIME_TEST ( CALLED_NUMBER VARCHAR2(50 BYTE),
                                            CALLED_DATE_TIME DATE, DURATION NUMBER );
    COMMIT;
    -- CREATE THE COMPARISON TABLE "TIME_TEST_COMPARE": THIS TABLE HOLDS WHAT SHOULD BE (BUT ISN'T) IDENTICAL CALL DATA.
    -- THE DATA CONTAINS DIFFERING NUMBER FORMATS, SLIGHTLY DIFFERENT CALL TIMES (ALLOW +/-60 SECONDS - THIS IS FOR A GOOD, ALBEIT UNHELPFUL, REASON)
    -- AND DURATIONS (ALLOW +/- 5 SECS)                                        
    CREATE TABLE TIME_TEST_COMPARE ( CALLED_NUMBER VARCHAR2(50 BYTE),
                                       CALLED_DATE_TIME DATE, DURATION NUMBER )                                        
    COMMIT;
    --CREATE INSERT DATA FOR THE MAIN TEST TIME TABLE
    INSERT INTO TIME_TEST ( CALLED_NUMBER, CALLED_DATE_TIME,
    DURATION ) VALUES (
    '7721345675', TO_DATE( '11/09/2011 06:10:21 AM', 'MM/DD/YYYY HH:MI:SS AM'), 202);
    INSERT INTO TIME_TEST ( CALLED_NUMBER, CALLED_DATE_TIME,
    DURATION ) VALUES (
    '7721345675', TO_DATE( '11/09/2011 08:10:21 AM', 'MM/DD/YYYY HH:MI:SS AM'), 19);
    INSERT INTO TIME_TEST ( CALLED_NUMBER, CALLED_DATE_TIME,
    DURATION ) VALUES (
    '7721345675', TO_DATE( '11/09/2011 07:10:21 AM', 'MM/DD/YYYY HH:MI:SS AM'), 35);
    INSERT INTO TIME_TEST ( CALLED_NUMBER, CALLED_DATE_TIME,
    DURATION ) VALUES (
    '7721345675', TO_DATE( '11/09/2011 09:10:21 AM', 'MM/DD/YYYY HH:MI:SS AM'), 30);
    INSERT INTO TIME_TEST ( CALLED_NUMBER, CALLED_DATE_TIME,
    DURATION ) VALUES (
    '7721345675', TO_DATE( '11/09/2011 06:18:47 AM', 'MM/DD/YYYY HH:MI:SS AM'), 6);
    INSERT INTO TIME_TEST ( CALLED_NUMBER, CALLED_DATE_TIME,
    DURATION ) VALUES (
    '7721345675', TO_DATE( '11/09/2011 06:20:21 AM', 'MM/DD/YYYY HH:MI:SS AM'), 20);
    COMMIT;
    -- CREATE INSERT DATA FOR THE TABLE WHICH NEEDS TO BE COMPARED:
    INSERT INTO TIME_TEST_COMPARE ( CALLED_NUMBER, CALLED_DATE_TIME,
    DURATION ) VALUES (
    '7721345675', TO_DATE( '11/09/2011 06:10:51 AM', 'MM/DD/YYYY HH:MI:SS AM'), 200);
    INSERT INTO TIME_TEST_COMPARE ( CALLED_NUMBER, CALLED_DATE_TIME,
    DURATION ) VALUES (
    '00447721345675', TO_DATE( '11/09/2011 08:10:59 AM', 'MM/DD/YYYY HH:MI:SS AM'), 21);
    INSERT INTO TIME_TEST_COMPARE ( CALLED_NUMBER, CALLED_DATE_TIME,
    DURATION ) VALUES (
    '07721345675', TO_DATE( '11/09/2011 07:11:20 AM', 'MM/DD/YYYY HH:MI:SS AM'), 33);
    INSERT INTO TIME_TEST_COMPARE ( CALLED_NUMBER, CALLED_DATE_TIME,
    DURATION ) VALUES (
    '+447721345675', TO_DATE( '11/09/2011 09:10:01 AM', 'MM/DD/YYYY HH:MI:SS AM'), 33);
    INSERT INTO TIME_TEST_COMPARE ( CALLED_NUMBER, CALLED_DATE_TIME,
    DURATION ) VALUES (
    '+447721345675#181345', TO_DATE( '11/09/2011 06:18:35 AM', 'MM/DD/YYYY HH:MI:SS AM')
    , 6);
    INSERT INTO TIME_TEST_COMPARE ( CALLED_NUMBER, CALLED_DATE_TIME,
    DURATION ) VALUES (
    '004477213456759777799', TO_DATE( '11/09/2011 06:19:58 AM', 'MM/DD/YYYY HH:MI:SS AM')
    , 17);
    COMMIT;
    /* --- QUERY TO UNDERTAKE MATCHING WHICH REQUIRES OPTIMISATION --------- */
    SELECT MAIN.CALLED_NUMBER AS MAIN_CALLED_NUMBER, MAIN.CALLED_DATE_TIME AS MAIN_CALL_DATE_TIME, MAIN.DURATION AS MAIN_DURATION,
         COMPARE.CALLED_NUMBER AS COMPARE_CALLED_NUMBER,COMPARE.CALLED_DATE_TIME AS COMPARE_CALLED_DATE_TIME,
         COMPARE.DURATION COMPARE_DURATION     
    FROM
    SELECT CALLED_NUMBER, CALLED_DATE_TIME, DURATION
    FROM TIME_TEST
    ) MAIN
    LEFT JOIN
    SELECT CALLED_NUMBER, CALLED_DATE_TIME, DURATION
    FROM TIME_TEST_COMPARE
    ) COMPARE
    ON INSTR(COMPARE.CALLED_NUMBER,MAIN.CALLED_NUMBER)<> 0
    AND MAIN.CALLED_DATE_TIME BETWEEN COMPARE.CALLED_DATE_TIME-(60/86400) AND COMPARE.CALLED_DATE_TIME+(60/86400)
    AND MAIN.DURATION BETWEEN MAIN.DURATION-(5/86400) AND MAIN.DURATION+(5/86400);

    What does your execution plan look like?

  • Select query performance improvement - Index on EDIDC table

    Hi Experts,
    I have a scenario where in I have to select data from the table EDIDC. The select query being used is given below.
      SELECT  docnum
              direct
              mestyp
              mescod
              rcvprn
              sndprn
              upddat
              updtim
      INTO CORRESPONDING FIELDS OF TABLE t_edidc
      FROM edidc
      FOR ALL ENTRIES IN t_error_idoc
      WHERE
      upddat GE gv_date1 AND
      upddat LE gv_date2 AND
      updtim GE p_time AND
      status EQ t_error_idoc-status.
    As the volume of the data is very high, our client requested to put up some index or use an existing one to improve the performance of the data selection query.
    Question:
    4.    How do we identify the index to be used.
    5.    On which fields should the indexing be done to improve the performance (if available indexes donu2019t cater to our case).
    6.    What will be the impact on the table performance if we create a new index.
    Regards ,
    Raghav

    Question:
    1.    How do we identify the index to be used.
    Generally the index is automatically selected by SAP (DB Optimizer )  ( You can still mention the index name in your select query by changing the syntax)
      For your select Query the second Index will be called automatically by the Optimizer, ( Because  the select query has u2018Updatu2019 , u2018uptimu2019 in the sequence before the u2018statusu2019 ) .
    2.    On which fields should the indexing be done to improve the performance (if available indexes donu2019t cater to our case).
    (Create a new Index with MANDT and the 4 fields which are in the where clause in sequence  )
    3.    What will be the impact on the table performance if we create a new index.
    ( Since the index which will be newly created is only the 4th index for the table, there shouldnu2019t be any side affects)
    After creation of index , Check the change in performance of the current program and also some other programs which are having the select queries on EDIDC ( Various types of where clauses preferably ) to verify that the newly created index is not having the negative impact on the performance. Additionally, if possible , check if you can avoid  into corresponding fields .
    Regards ,
    Seth

  • Performance Tuning for A016 (cluster table) Query

    Dear SDNers,
    Issue:
    The report runs  successfully sometimes and sometimes the report gets timed out.
    My findings
    Query which is taking a  long time to execute is the query on A016(cluster Table) to fetch the condition details
    SELECT kschl
             evrtn
             evrtp
             knumh
             FROM a016 INTO TABLE t_a016
             FOR ALL ENTRIES IN t_ekpo
             WHERE
             kappl EQ c_m (Application)
             AND kschl IN s_kschl
             AND evrtn = t_ekpo-ebeln
             AND evrtp = t_ekpo-ebelp.
    where t_ekpo contains entries (4354)from ekko and ekpo based on the selection screen entries.
    I see that a016 is a cluster table that is being used here and t_a016 contains (390*) records after the above fetch.
    Dear readers,Please help me as to what has to be taken care of inorder to fine tune this select query?
    what are the things that i need to make corrections in.
    How can i make this fetch effective and faster?
    Please help me with your inputs.
    Regards,
    SuryaD.
    Edited by: SuryaD on Oct 26, 2009 6:29 PM

    Hi,
    1) Try to hit the table A016 with only unique entries of t_ekpo for EBELN and EBELP...
    Use some temp table lt_ekpo = t_ekpo
    i.e. sort lt_ekpo by ebeln ebelp
    delete adjacent duplicates from lt_ekpo comparing ebeln ebelp.
    Now write you select query as below...So that the table might be hit with less number of entries...
    SELECT kschl
    evrtn
    evrtp
    knumh
    FROM a016 INTO TABLE t_a016
    FOR ALL ENTRIES IN lt_ekpo
    WHERE
    kappl EQ c_m (Application)
    AND kschl IN s_kschl
    AND evrtn = lt_ekpo-ebeln
    AND evrtp = lt_ekpo-ebelp.
    Please note that there will be no change in the output data if you hit with duplicate entries/unique as FOR ALL ENTRIES will fetch only unique entries matching the where condition.
    2) Order of where conditon fields should be same as the order in table for better performance...
    3) If you find any index on the table, try to include the fields in where condition(if possible) for better performance
    Hope this helps
    Regards
    Shiva

  • Performance Impact of Unique Constraint on a Date Column

    In a table I have a compound unique constraint which extends over 3 columns. As a part of functionality I need to add another DATE column to this unique constraint.
    I would like to know the performance implications of adding a DATE column to the unique constraint. Would the DATE column behave like another VARCHAR2 or NUMBER column, or would it degrade the performance significantly?
    Thanks
    Message was edited by:
    user627808

    What performance are you concerned about degrading? Inserts? Or queries? If you're talking about queries, what sort of access path are you concerned about?
    Are you concerned that merely changing the definition of the unique constraint would impact performance? Or are you worried that whatever functional change you are making would impact performance (i.e. if you are now retaining historical data in the table rather than just updating it)?
    Regardless of the performance impact, unique indexes (and unique constraints) need to be correct. If you need to allow duplicates on the 3 current columns with different dates, then you would need to change the unique constraint definition regardless of the performance impact. Fast and wrong generally isn't going to be preferrable to slow and right.
    Generally, though, there probably is no reason to be terribly concerned about performance here. Indexing a date is no different than indexing any other primitive data type.
    Justin

  • SQL Server 2014 Bug - with Clustered Index On Temp Table with Identity Column

    Hi,
    Here's a stored procedure.  (It could be shorter, but this will show the problem.)
              CREATE PROCEDURE dbo.SGTEST_TBD_20141030 AS
              IF OBJECT_ID('TempDB..#Temp') IS NOT NULL
                 DROP TABLE #Temp
              CREATE TABLE #Temp
               Col1        INT NULL
              ,Col2        INT IDENTITY NOT NULL
              ,Col3        INT NOT NULL
              CREATE CLUSTERED INDEX ix_cl ON #Temp(Col2)
              SET IDENTITY_INSERT #Temp ON;
              RAISERROR('Preparing to INSERT INTO #Temp...',0,1) WITH NOWAIT;
              INSERT INTO #Temp (Col1, Col2, Col3)
              SELECT 1,2,3
              RAISERROR('Insert Success!!!',0,1) WITH NOWAIT;
              SET IDENTITY_INSERT #Temp OFF;
    In SQL Server 2014, If I execute this (EXEC dbo.SGTEST_TBD_20141030)   It works.   If I execute it a second time - It fails hard with: 
            Msg 0, Level 11, State 0, Line 0
            A severe error occurred on the current command.  The results, if any, should be discarded.
            Msg 0, Level 20, State 0, Line 0
            A severe error occurred on the current command.  The results, if any, should be discarded.
    In SQL Server 2012, I can execute it over and over, with no problem.  I've discovered two work-a-rounds:   
    1) Add "WITH RECOMPILE" to the SP CREATE/ALTER statement, or 
    2) Declare the cluster index in the TABLE CREATE statement, e.g. ",UNIQUE CLUSTERED (COL2)" 
    This second option only works though, if the column is unique.    I've opted for the "WITH RECOMPILE" for now.  But, thought I should share.

    Hi,
    I did not get any error Message:
             CREATE TABLE #Temp
               Col1        INT NULL
              ,Col2        INT IDENTITY NOT NULL
              ,Col3        INT NOT NULL
              CREATE CLUSTERED INDEX ix_cl ON #Temp(Col2)
              SET IDENTITY_INSERT #Temp ON;
              RAISERROR('Preparing to INSERT INTO #Temp...',0,1) WITH NOWAIT;
              INSERT INTO #Temp (Col1, Col2, Col3)
              SELECT 1,2,3
              RAISERROR('Insert Success!!!',0,1) WITH NOWAIT;
              SET IDENTITY_INSERT #Temp OFF;
    SELECT * FROM #Temp
    OUTPUT:
    Col1 Col2
    Col3
    1 2 3
    1 2 3
    1 2 3
    Select @@version
    --Microsoft SQL Server 2012 (SP1) - 11.0.3000.0 (X64) 
    Oct 19 2012 13:38:57 
    Copyright (c) Microsoft Corporation
    Enterprise Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)
    Thanks Shiven:) If Answer is Helpful, Please Vote

  • AQ tables have DATE columns in 9i and TIMESTAMP in 10g

    Hi,
    I created a queue table on 9i and 10g database's using
    eg:
    dbms_aqadm.create_queue_table(queue_table => 'TEST',
    queue_payload_type => 'RAW',
    multiple_consumers => TRUE,
    compatible => '8.1.3');
    But in 9i
    ENQ_TIME DATE
    and 10g
    ENQ_TIME TIMESTAMP(6)
    Why does date column change to timestamp?
    Thanks
    Reynold.

    My strong suggestion would be to convert all dates to char and then go from there. Doing anything other than that will force Applications to convert the dates (and I can only assume the timestamps). It is the nature of the application/datatype design. Converting everything to a CONSISTANT format, even if that is a varchar goes a long way to removing many unknowns.
    My two cents,
    Scott

  • Regarding performance tuning for BSEG & BKPF table data fetch

    Hi Friends:
       Plz see the below select queries. This is really impacting the performance of my report. Plz suggest the steps to increase the performance of the report.Points will be rewarded.
    Thanks:
    FORM GET_DATA .
    Selecting the Document number from BSEG table
      SELECT BELNR BUKRS FROM BSEG INTO TABLE L_DOC_NO
                                   WHERE BUKRS IN S_BUKRS
                                   AND   GJAHR = P_GJAHR
                                   AND   HKONT IN S_SAKNR.
      IF SY-SUBRC <> 0.
        MESSAGE ID 'ZTFI' TYPE 'E' NUMBER 006.
      ENDIF.
      CLEAR L_DOC_NO.
      SORT L_DOC_NO BY BELNR.
    Selecting the Document Number Based on the selection-screen.
      SELECT BELNR BUKRS BUDAT CPUDT  BLART MONAT FROM BKPF INTO TABLE
    L_BKPF
      FOR ALL ENTRIES IN L_DOC_NO
                            WHERE BUKRS = L_DOC_NO-BUKRS AND
                                  BELNR = L_DOC_NO-BELNR AND
                                  GJAHR = P_GJAHR AND
                                  BUDAT IN S_BUDAT AND
                                  MONAT IN S_MONAT.
      IF SY-SUBRC <> 0.
        MESSAGE ID 'ZTFI' TYPE 'E' NUMBER 006.
      ENDIF.
    *Fetch the Line Items
      SORT L_BKPF BY BELNR.
      SELECT BELNR BUKRS BUZEI HKONT  SHKZG WRBTR FROM BSEG INTO TABLE
    L_BSEG
                                    FOR ALL ENTRIES IN L_BKPF
                                 WHERE BUKRS = L_BKPF-BUKRS
                                 AND   BELNR = L_BKPF-BELNR
                                 AND   GJAHR = P_GJAHR
                                 AND   BUZEI BETWEEN '001' AND '999'.

    Hi,
    Let me understand your code first.
    The below code (the 2 selects) gets data from BSEG first and then gets data from BKPF table.
    "*Selecting the Document number from BSEG table
    SELECT BELNR BUKRS FROM BSEG INTO TABLE L_DOC_NO
    WHERE BUKRS IN S_BUKRS
    AND GJAHR = P_GJAHR
    AND HKONT IN S_SAKNR.
    IF SY-SUBRC 0.
    MESSAGE ID 'ZTFI' TYPE 'E' NUMBER 006.
    ENDIF.
    CLEAR L_DOC_NO.
    SORT L_DOC_NO BY BELNR.
    "*Selecting the Document Number Based on the selection-screen.
    SELECT BELNR BUKRS BUDAT CPUDT BLART MONAT FROM BKPF INTO TABLE L_BKPF
    FOR ALL ENTRIES IN L_DOC_NO
    WHERE BUKRS = L_DOC_NO-BUKRS AND
    BELNR = L_DOC_NO-BELNR AND
    GJAHR = P_GJAHR AND
    BUDAT IN S_BUDAT AND
    MONAT IN S_MONAT.
    IF SY-SUBRC 0.
    MESSAGE ID 'ZTFI' TYPE 'E' NUMBER 006.
    ENDIF.
    The below code, can't you avoid by taking all the fields required on your 1st select on BSEG table?
    *Fetch the Line Items
    SORT L_BKPF BY BELNR.
    SELECT BELNR BUKRS BUZEI HKONT SHKZG WRBTR FROM BSEG INTO TABLE
    L_BSEG
    FOR ALL ENTRIES IN L_BKPF
    WHERE BUKRS = L_BKPF-BUKRS
    AND BELNR = L_BKPF-BELNR
    AND GJAHR = P_GJAHR
    AND BUZEI BETWEEN '001' AND '999'.
    Please check the below blog on "Performance of Nested Loops" by Rob Burbank which would be really helpful.
    /people/rob.burbank/blog/2006/02/07/performance-of-nested-loops
    Hope this helps. Rwd points if helpful.
    Thanks,
    Balaji

  • Issues with using XMLType indexes against a table with XMLType column

    I am attempting to use an XMLIndex with a Structured Component and not having too much luck. Not much data in metalink nor is the documentation very helpful:
    http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10492/xdb_indexing.htm#BCGHGIGC
    The table DDL is as follows:
    CREATE TABLE ECI_SCHEMA.REV_ITEM_EARN_DTL_VIRTUAL(
    REV_ITEM_EARN_DTL_ID_NBR NUMBER(16,0) NOT NULL,
    UNIQ_MSG_ID_NBR VARCHAR2(50) NOT NULL,
    REV_ITEM_BILL_DTL_ID_NBR NUMBER(16,0),
    PLAN_RACN_NBR NUMBER(10,0) NOT NULL,
    INV_DTL_IMG SYS.XMLType NOT NULL,
    NON_INV_DTL_IMG BLOB NOT NULL,
    PART_KEY_CD GENERATED ALWAYS AS (MOD(PLAN_RACN_NBR,5)) VIRTUAL,
    LAST_UPDT_TMSTP TIMESTAMP(6) NOT NULL,
    INV_ID_NBR NUMBER(16,0),
    ITEM_STATUS_CD VARCHAR2(1) DEFAULT 'A' NOT NULL
    LOB (NON_INV_DTL_IMG) STORE AS NON_IDI_LOB (CHUNK 8192 PCTVERSION 10 CACHE)
    TABLESPACE ECI_DATA
    PARTITION BY RANGE (PART_KEY_CD)
    PARTITION RIED_DAY0_PART
    VALUES LESS THAN (1)
    TABLESPACE ECI_DATA
    PARTITION RIED_DAY1_PART
    VALUES LESS THAN (2)
    TABLESPACE ECI_DATA
    PARTITION RIED_DAY2_PART
    VALUES LESS THAN (3)
    TABLESPACE ECI_DATA
    PARTITION RIED_DAY3_PART
    VALUES LESS THAN (4)
    TABLESPACE ECI_DATA
    PARTITION RIED_MAXVAL_PART
    VALUES LESS THAN (MAXVALUE)
    TABLESPACE ECI_DATA
    XMLTYPE COLUMN "INV_DTL_IMG" STORE AS OBJECT RELATIONAL
    XMLSCHEMA "someXdbDocument.xsd"
    ELEMENT "revenueInvoice"
    According to the documentation, I should be able to create a structured XMLIndex on the XMLType column with the following syntax:
    SQL> create index eci_schema.rev_item_earn_dtl_virt_xmlix on eci_schema.rev_item_earn_dtl_virtual
    2 (INV_DTL_IMG)
    3 INDEXTYPE IS XDB.XMLIndex
    4 parameters ('PATH TABLE RIED_PATH_TABLE')
    5 local;
    When I do this, I get the following error:
    create index eci_schema.rev_item_earn_dtl_virt_xmlix on eci_schema.rev_item_earn_dtl_virtual
    ERROR at line 1:
    ORA-29958: fatal error occurred in the execution of ODCIINDEXCREATE routine
    ORA-30959: The indexed column is not stored in CLOB.
    What am I doing wrong? Based on the Oracle documentation, I was under the impression that 11.2 XMLIndex would work with Object Relational storage. Is this not the case?

    CREATE INDEX ECI_SCHEMA.REV_ITEM_EARN_DTL_IX7
           ON ECI_SCHEMA.REV_ITEM_EARN_DTL
                      extractValue(inv_dtl_img, '/revenueInvoice/service/transportation/mstrTrkngNbr')
    TABLESPACE ECI_REV_ITEM_EARN_DTL_IX7_ITS
    LOGGING
    PARALLEL(DEGREE 8 INSTANCES 1)
    LOCAL
    /Elements that occur at most once in each document can be indexed using extractValue(). Despite the fact that the index appears to be a functional index, when we create the index we automatically re-write the create index into a normal btree index on the column that contains the value for the element identified by the xpath.
    Eg in the case of a functional index based on extractValue, defined on XMLType using Object relational storage, with an xpath that identifies a node that occurs at most once in each document is not a functional index, it's re-written into a plain old vanilla btree index. You can actually check this by looking in the system tables
    Eg
    SQL> connect system/oracle
    Connected.
    SQL> select table_name, index_name from all_indexes where owner = 'OE' and table_name = 'PURCHASEORDER';
    TABLE_NAME                     INDEX_NAME
    PURCHASEORDER                  LINEITEM_TABLE_MEMBERS
    PURCHASEORDER                  ACTION_TABLE_MEMBERS
    PURCHASEORDER                  SYS_C0011037
    SQL> alter session set current_schema = OE
      2  /
    Session altered.
    SQL> create unique index PO_REF_INDEX on PURCHASEORDER (extractValue(object_value,'/PurchaseOrder/Reference'));
    Index created.
    SQL> set lines 250
    SQL> select index_name, index_type from all_indexes where owner = 'OE' and table_name = 'PURCHASEORDER';
    INDEX_NAME                     INDEX_TYPE
    PO_REF_INDEX                   NORMAL
    LINEITEM_TABLE_MEMBERS         NORMAL
    ACTION_TABLE_MEMBERS           NORMAL
    SYS_C0011037                   NORMAL
    SQL> select * from dba_ind_expressions where table_name = 'PURCHASEORDER' and index_owner = 'OE'
      2  /
    no rows selectedFrom the above we can see that the index created on extractValue has been re-written in a plain old vanilla BTREE index, and there is no definition for it in dba_ind_expressions So assuming you were able to create the index and insert the data you should find that your index is not a functional index.
    ]

  • Importing data tables into data tablespace and indexes into tablespaces

    Hi
    I want to import data into new schema and i want to store tables into data tablespaces and index into index tablespace ...can anyone tell me how it will possible...

    I want to import data into new schema and i want to store tables into data tablespaces and index into index tablespace ...can anyone tell me how it will possible...
    imp userid=/user/passwd show=y indexfile=import.sql indexes=n full=y
    imp userid=/user/passwd show=y indexfile=import2.sql full=y
    Edit the import.sql and import2.sql to modify the tables' tablespace and indexes tablespace.
    execute import.sql the script in the database. this will create the tables in their respective tablespace.
    imp userid=/user/passwd full=y ignore=y indexes=n constraints=y - to import just the data since the tables have already been created.
    imp userid=/user/passwd full=y ignore=y rows=n  - to import just the indexes since the tables and data have already been imported.

  • NOW LIVE: Oracle Database 11g - Performance Tuning Exam (1Z0-054)

    !http://blogs.oracle.com/certification/ORC-0128.jpg!
    The new *"Oracle Database 11g: Performance Tuning" certification exam (1Z0-054)* is now live, which is a single exam requirement for Oracle 11g DBA OCPs to earn the Oracle Database 11g Performance Tuning Certified Expert (OCE) certification.</p>
    <p align="justify">This certification endorses those database administrators, support engineers, and technical consultants who have demonstrated their knowledge and skills using Oracle Database 11g automatic tuning features, including SQL Tuning Advisor, SQL Access Advisor, Automatic Workload Repository and Automatic Database Diagnostic Monitor.</p>
    <p align="justify">Candidates taking this exam at test centers will now receive their exam scores and pass/fail status immediately at the completion of their exam. Score reports have just been shipped to those candidates who participated in the beta period. If you participated in beta testing and did not yet receive your score report, please contact [email protected]</p>
    <p align="justify"><strong>QUICK LINKS</strong></p>
    <ul><li>Certification Track: Oracle Database 11g Performance Tuning Certified Expert (OCE)</li>
    <li>Certification Exam: 1Z0-054 &ndash; Oracle Database 11g: Performance Tuning</li>
    <li>Stay Up To Date: Oracle Certification Blog | Oracle Certification Website</li>
    </ul>

    Naveen Kumar C wrote:
    Hi,
    y
    I want to take the certification Oracle Database 11g: Performance Tuning exam 1Z0-054 and want to write the exam.
    To earn the OCE credentials, I know that we need to take training from Oracle University. I am not an OCP currently.
    Can I write the exam now and later take the course to meet the certification requirements? I know it is not the right way, but I can not pay $3000 for the course as of now. I can write the exam through self study. I want to check if I can take the exam now and later take the course.
    Is it mandatory to take the course before taking the exam?
    Thanks,
    naveen.Indeed you can take the exam now, and subsequently earn the 11g PERFTUNE OCE credential when you either:
    1) complete, submit and get verified the OU authorised 11g perftune course (possible but seems a little cart before horse).
    or
    2) Become 11g DBA OCP.

  • Creating indexes in temprory table

    Guys here is my temp table
    -- Create table
    create global temporary table EMP_TEMP
    EMP_NO NUMBER(4),
    EMP_SALARY NUMBER(7),
    EMP_NAME VARCHAR2(30),
    on commit preserve rows;
    Now how can I created indexes on EMP_SALARY or EMP_NAME .I am not looking for primary or unique keys but just indexes.
    I tried create index command but it say it is unsupported for temporory table.
    please help.
    thx

    manushetty,
    Index on temporary table, like data from temporary table, is not persistant. Also you cannot have storage clause, or tablespace...
    From my index which I created above :
      1  select index_name,tablespace_name,pct_free,
      2         ini_trans,max_trans,initial_extent,min_extents,max_extents
      3  from dba_indexes
      4* where index_name = 'TOTI'
    SQL> /
    INDEX_NAME                     TABLESPACE_NAME                  PCT_FREE
    INI_TRANS  MAX_TRANS INITIAL_EXTENT MIN_EXTENTS MAX_EXTENTS
    TOTI                                                                  10
             2        255
    SQL> As you can see, there is no tablespace, and no storage clause (extent)
    If I create the same index on a permanent table, all these parameters are not null :
    SQL> create index toti on emp(sal);
    Index created.
      1  select index_name,tablespace_name,pct_free,
      2         ini_trans,max_trans,initial_extent,min_extents,max_extents
      3  from all_indexes
      4* where index_name = 'TOTI'
    SQL> /
    INDEX_NAME                     TABLESPACE_NAME                  PCT_FREE
    INI_TRANS  MAX_TRANS INITIAL_EXTENT MIN_EXTENTS MAX_EXTENTS
    TOTI                           SYSTEM                                 10
             2        255          65536           1  2147483645HTH,
    Nicolas.

  • Index on a Table

    How does oracle utilize an index on table? Suppose that I had a query:
    SELECT emp.employee_id,
    emp.employee_firstname,
    emp.employee_lastname,
    emp.department_id,
    emp.position_id,
    emp.date_of_birth,
    emp.date_hired
    FROM hr_employee emp
    WHERE emp.department_id = 10;
    There is an index HR_EMPLOYEE_IDX1 on table HR_EMPLOYEE for column EMPLOYEE_ID. Would the HR_EMPLOYEE_IDX1 be use by the oracle? Thanks.

    In this situation ( I suppose that you are using example schema - HR) your query will use index on employee_id column even if no index is on department_id
    Execution Plan
    0 SELECT STATEMENT Optimizer=CHOOSE
    1 0 TABLE ACCESS (BY INDEX ROWID) OF 'EMP5'
    2 1 INDEX (UNIQUE SCAN) OF 'EMPLOYEE_ID_PK_EMP5' (UNIQUE)
    but it is not a rule, even if you have indexes on your columns the cost based optimizer can choose to do full table scan on your table (FTS is not an evil! sometimes can be quicker tha index lookup).
    If you would like to execution plans of your queries you could use explain plan for select .... - instruction
    or use an autotrace feature of sql*plus - to configure it
    execute script $ORACLE_HOME/sqlplus/admin/plustrce.sql
    grant plustrace to hr;
    conn hr/hr
    set autotrace on
    tun queries
    set autotrace off
    Best Regards
    Krystian Zieja / mob

  • No records in Azure databrowser viewing tables with many columns.

    Yesterday I encountered an issue while browsing a table created in Azure.
    I created a new database in Azure and in this database I created and populated several tables, containing one very big table.
    The big table has 239 columns.
    I succeeded in populating this table with our in-company table-data, means by a dtsx-package. No problem this far.
    When I query the table from SQL Server Management Studio, I get correct results.
    However, the databrowser on the azure-site itself does not show any data for this table. That’s a little disappointing regarding the fact that there are more than 76000 records in this table. Refresh didn’t help.
    When I browse smaller tables with less data-columns, I do get data in this data-browser.
    Is this a known issue or do you know a solution for this issue ?
    Kind regards,
    Fred Silven
    AEB Amsterdam
    The Netherlands.

    Hello,
    Based on your description, you want to edit data of a large table in the Management Portal of SQL database, but it is not return rows in GUI Design tab.  Can you get the data when select "TOP 200 rows"?
    Since there are 239 columns and 76000 rows in the table, the Portal may take a bit long time to load all data in GUI. Please try to using T-SQL statement to perform the select or update operation and specify condition in WHERE clause to load the
    needed data.
    Regards,
    Fanny Liu
    Fanny Liu
    TechNet Community Support

Maybe you are looking for

  • Blob setBytes and setBinaryStream Clarification Needed

    I'm writing a JDBC driver for SQL Server and working on the Blob implementation details. One thing that is not clear in the JDBC spec to me at least is the behavior of the call to setBytes and to setBinaryStream on a Blob. Say for a simple example I

  • New to iPhoto: Database Corruption and iPhoto Package

    Coming from the PC I'm used to individual files with Picasa and Photoshop and I'm confused about a few things: 1. Is the iPhoto database separate from the iPhoto package file that stores all of the images? 2. And if you were to lose your database bec

  • Some members of distribution list get email 15 minutes after the others

    We have a strange problem. We've migrated cross forrest from an Exchange 2007 to an Exchange 2013. Everything seems to be ok, except for one issue we have which is that sometimes an email sent to a distribution group is received 15 minutes later by 2

  • How to show hard drive icon on my desktop on iOS x

    I'm using macbook pro and have iOS x. I want to have my hard drive icon appear on my desktop. Currently, it is not showing up. I would appreciate for an how to instruction.

  • Locking files

    i have a few word documents on my computer that i don't need seen by friends and family that occasionally use it. is there a way i can lock the files, so that a password is required to open any of them? thanks.