Performance: Open SQL vs. Native SQL (Oracle)

Hi everybody,
I have an interesting issue here. For a DB selection I use an Open SQL query from a table view into an internal table. It works fine, but the performance is not very well. The SELECT uses LIKE and wildcards (%) to search for customer master data (names and address fields).
Because of the bad performance I made some tests in transaction DB02 with native SQL, but exactly the same SELECT structure. It looks like this:
  SELECT *
    FROM zzrm_cust_s_hlp
   WHERE client = 100
     AND mc_name1      LIKE '<name>%'
     AND mc_name2      LIKE '<name>%'
     AND valid_from    <= <timestamp>
     AND valid_to      >= <timestamp>
Ok, now I tried exactly the same SELECT statement with the same data to search for (<name> and <timestamp) with Open SQL and Native SQL. The Difference is quite suprising, the Native SQL query is about 5-10 times faster (arount 1 sec) than the Open SQL query (around 5-10 sec). Even with the LIKE keywords and the wildcards.
Any ideas what could be the problem with the Open SQL query?
And: what can I do to achive the same performance as with the Native SQL query?
Kind regards and thanks in advance for any help,
Matthias

Ok, here is the the SQL explaination from the DB02 query:
SELECT STATEMENT ( Estimated Costs = 194 , Estimated #Rows = 1 )
       9 COUNT STOPKEY
         Filter Predicates
           8 NESTED LOOPS
             ( Estim. Costs = 193 , Estim. #Rows = 1 )
             Estim. CPU-Costs = 1,665,938 Estim. IO-Costs = 193
               5 NESTED LOOPS
                 ( Estim. Costs = 144 , Estim. #Rows = 98 )
                 Estim. CPU-Costs = 1,162,148 Estim. IO-Costs = 144
                   2 TABLE ACCESS BY INDEX ROWID BUT000
                     ( Estim. Costs = 51 , Estim. #Rows = 93 )
                     Estim. CPU-Costs = 468,764 Estim. IO-Costs = 51
                     Filter Predicates
                       1 INDEX SKIP SCAN BUT000~NAM
                         ( Estim. Costs = 6 , Estim. #Rows = 93 )
                         Search Columns: 1
                         Estim. CPU-Costs = 59,542 Estim. IO-Costs = 6
                         Access Predicates Filter Predicates
                   4 TABLE ACCESS BY INDEX ROWID BUT020
                     ( Estim. Costs = 1 , Estim. #Rows = 1 )
                     Estim. CPU-Costs = 7,456 Estim. IO-Costs = 1
                     Filter Predicates
                       3 INDEX RANGE SCAN BUT020~0
                         ( Estim. Costs = 1 , Estim. #Rows = 1 )
                         Search Columns: 2
                         Estim. CPU-Costs = 3,661 Estim. IO-Costs = 1
                         Access Predicates
               7 TABLE ACCESS BY INDEX ROWID ADRC
                 ( Estim. Costs = 1 , Estim. #Rows = 1 )
                 Estim. CPU-Costs = 5,141 Estim. IO-Costs = 1
                 Filter Predicates
                   6 INDEX UNIQUE SCAN ADRC~0
                     Search Columns: 4
                     Estim. CPU-Costs = 525 Estim. IO-Costs = 0
                     Access Predicates
And this is the one from the Open SQL query in ABAP:
SELECT STATEMENT ( Estimated Costs = 15,711 , Estimated #Rows = 29 )
       7 NESTED LOOPS
         ( Estim. Costs = 15,710 , Estim. #Rows = 29 )
         Estim. CPU-Costs = 3,021,708,117 Estim. IO-Costs = 15,482
           4 NESTED LOOPS
             ( Estim. Costs = 15,411 , Estim. #Rows = 598 )
             Estim. CPU-Costs = 3,018,711,707 Estim. IO-Costs = 15,183
               1 TABLE ACCESS FULL BUT020
                 ( Estim. Costs = 9,431 , Estim. #Rows = 11,951 )
                 Estim. CPU-Costs = 2,959,067,612 Estim. IO-Costs = 9,207
                 Filter Predicates
               3 TABLE ACCESS BY INDEX ROWID ADRC
                 ( Estim. Costs = 1 , Estim. #Rows = 1 )
                 Estim. CPU-Costs = 4,991 Estim. IO-Costs = 1
                 Filter Predicates
                   2 INDEX UNIQUE SCAN ADRC~0
                     Search Columns: 4
                     Estim. CPU-Costs = 525 Estim. IO-Costs = 0
                     Access Predicates
           6 TABLE ACCESS BY INDEX ROWID BUT000
             ( Estim. Costs = 1 , Estim. #Rows = 1 )
             Estim. CPU-Costs = 5,011 Estim. IO-Costs = 1
             Filter Predicates
               5 INDEX UNIQUE SCAN BUT000~0
                 Search Columns: 2
                 Estim. CPU-Costs = 525 Estim. IO-Costs = 0
                 Access Predicates
Of course I can see the difference.
But since the statements are identical, I don't understand why this difference exists
Thanks for your help!
Kind regards, Matthias

Similar Messages

  • CREATE VIEW in ABAP (Open SQL or Native SQL)

    Hi all you experts!
    I want to create a VIEW in ABAP. I have created Table Views using ABAP Dictionary (in transaction SE11), I don't have any problem with them.
    But, what I need is to create a dynamic view, I mean, a view that can be created/replaced (or modified) at runtime. Is this possible with SAP Open SQL, I don't think so... that is why I tried to created using native SQL but it is not working.
    Here is the code:
      EXEC SQL.
        CREATE VIEW [ZMXRFIV_GLPCA]
          AS SELECT
             T1.GL_SIRID,
             T1.POPER,
             T1.RBUKRS,
             T1.RPRCTR,
             T1.RACCT,
             T1.HSL
          FROM
             GLPCA T1
          INNER JOIN
             SKA1 T2
          ON
             T1.RACCT = T2.SAKNR
          WHERE
            T1.RVERS      =  '000'
            AND T1.RYEAR  =  '2008'
            AND T1.KOKRS  =  'PI01'
            AND T2.KTOPL  =  'PI00'
            AND T2.XBILK  <> 'X'.
      ENDEXEC.
    I have tried using quotes (") for the view name, parenthesis and even using only the name but this make no difference.
    Do any of you experts have any idea?
    PS: After creating the view I need to do a SELECT INTO TABLE to that view and finally delete this view and continue working with the data on the internal table.

    Hi ,
    oh yes it is an object (well, how the database should handle it in any context if it wasn't)
    i.e. for ORACLE you would have several thousands of them:
    select count(*) from dba_objects where object_type ='VIEW'
    If you avoid some kind of foreground processing (i.e. pull the data over the network) and handle the processing inside the database it can improve somehow performance a little (i.e. using the retieved rows of the view to stuff into a database table directly). But his may not always possible...
    bye
    yk

  • Convert OpenSQL to Native SQL

    Does someone know of a function module that will accept a SQL statement in OpenSQL format, and convert it to Native SQL (Oracle) format?
    We cannot turn on a trace in our system.
    Thanks.

    Check these threads ...
    Converting OPEN SQL to NATIVE SQL
    Open SQL to Native SQL conversion
    Regards,
    Santosh
    Message was edited by: Santosh Kumar P

  • SELECT ROWID using ABAP without Native SQL ?

    Hi All,
    is that possible to query Oracle ROWID from ABAP without using Native SQL ? Please advise.
    Thank You and Best Regards
    FL

    Since this is usually not relevant for application programming and also database specific, I'm fairly sure this information hidden by the DBI and you cannot access it via Open SQL, so native SQL seems to be your only choice.
    Thomas

  • Open VS. Native

    Hi,
    I need a list of advantages and disadvantages of Native/Open SQL.
    Thanks.

    hi
    Types of SQL’s
    Native SQL
    Open SQL
    Open SQL commands
    SELECT
    INSERT
    UPDATE
    MODIFY
    DELETE
    OPEN CURSOR, FETCH,  CLOSE CURSOR
    Open SQL – Return codes
    Sy-subrc
         - Return value after specific ABAP/4 statements
    Sy-dbcnt
         - DB operations: Number of elements in the edited dataset
    Native SQL
    EXEC SQL [PERFORMING  ENDEXEC.
    regards
    vijay
    reward points if helpful

  • Performance issue using Native SQL

    Hi
        I am getting the data from Oracle database using Native SQL in ABAP. I am facing performance problem when i am using Native SQL to get data from Oracle database.Its been very slow and getting timed out.
    This is the code i am using for this.
    EXEC SQL PERFORMING BUILD_TAB.
    Get the territory id
        SELECT TERR_ID
          FROM DWPROD.VW_ARDETAIL_PRD1@DWP
          INTO :IT_TERR-TERR_ID
               :DG_TERR_ID
         WHERE COMPANY     = :dt_output-bukrs
           AND PAY_ADDR_ID = :dt_output-kunnr
           AND DOC_NO      = :dt_output-belnr
           AND DOC_ITEM_NO = :dt_output-buzei
      ENDEXEC.
      IF sy-dbcnt >= 1.
        READ TABLE it_terr INDEX 1.
        dg_terr_id = it_terr-terr_id.
        EXEC SQL.
    Get the Saled rep id, name
          SELECT MR_USER_ID,
                 MR_NAME
            FROM DWPROD.VW_TERR@DWP
            INTO :dt_output-srep_id,
                 :dt_output-srep_name
           WHERE TERR_ID = :DG_TERR_ID
        ENDEXEC.
    *Get sales manager id and sales manager name
        EXEC SQL.
          SELECT SALES_GRP_ID
            FROM DWPROD.VW_TERRRPT@DWP
            INTO :DG_SGRPID
           WHERE TERR_ID = :DG_TERR_ID
        ENDEXEC.
        IF sy-dbcnt >= 1.
          EXEC SQL.
            SELECT MGR_USER_ID,
                   MGR_NAME
              FROM DWPROD.VW_SGRP@DWP
              INTO :dt_output-sman_id,
                   :dt_output-sman_name
             WHERE SALES_GRP_ID = :DG_SGRPID
          ENDEXEC.
        ENDIF.
      ENDIF.
    Can any one suggest a solution to improve the performance.
    Thnaks
    Vianney

    Hi John!
    Looks like you need just one entry out of the tables, but you select 'into table'.
    Try to add a 'up to 1 rows' restriction, then Oracle will be much faster with the execution.
    To get an idea, who this parameter looks like in native SQL for Oracle, write a simple test program with an open SQL statement (including this parameter / select single) and run a SQL-trace (ST05). Here you can see in 'explain' how native translation looks like, can also maintain some small tests with 'enter SQL statement'.
    Regards,
    Christian

  • Performance of native sql query detoriates

    Dear Experts,
    The performance of my native SQL query is bad. On the database the query takes less than 5 seconds to process. From my abap program I get a session timeout dump after 10 minutes. What might be the possible reason.
    Warm Regards,
    Abdullah

    I am not a DBA, but this is a wild guess.
    I have a native SQL query. It was running fine all morning(transported it to production today). By afternoon the report was not giving any output.
    I went to the MS SQL query analyzer and executed the query, it returned the results in less than 5 seconds. The same query when I was executing from SAP using native SQL took more than 10 minutes and gave a dump(time exceeded).
    My database guy asked me to execute the following on the database. Dbcc dbreindex('tablename')
    The report is running fine since then. I am still not satisfied if this is the reason the performance is back on track, but yeah the report is running fine again. There seems to be some problem with the indexes.
    I am using standard classes provided by SAP to execute my query and after execution the resultset reference object is being closed, I am closing the connection.
    the code is as below.
          PERFORM:
            connect               USING con_name con_ref,
            select_into_table     USING con_ref,
            disconnect            USING con_ref.
    *  FORM connect
    *  Connects to the database specified by the logical connection name
    *  P_CON_NAME which is expected to be specified in table DBCON. In case
    *  of success the form returns in P_CON_REF a reference to a connection
    *  object of class CL_SQL_CONNECTION.
    *  --> P_CON_NAME  logical connection name
    *  <-- P_CON_REF   reference to a CL_SQL_CONNECTION object
    FORM connect  USING    p_con_name TYPE dbcon-con_name
                           p_con_ref  TYPE REF TO cl_sql_connection
                           RAISING cx_sql_exception.
    * if CON_NAME is not initial then try to open the connection, otherwise
    * create a connection object representing the default connection.
      IF p_con_name IS INITIAL.
        CREATE OBJECT p_con_ref.
      ELSE.
        p_con_ref = cl_sql_connection=>get_connection( p_con_name ).
      ENDIF.
    ENDFORM.                    " connect
    *  FORM select_into_table
    *  Selects some rows from the test table and fetches the result rows
    *  into an internal table whose row structure corresponds to the
    *  queries select list columns.
    FORM select_into_table
      USING   p_con_ref TYPE REF TO cl_sql_connection
      RAISING cx_sql_exception.
      DATA:
        l_stmt         TYPE string,
        l_stmt_ref     TYPE REF TO cl_sql_statement,
        l_dref         TYPE REF TO data,
        l_res_ref      TYPE REF TO cl_sql_result_set,
    *Data related query
        l_itab         TYPE TABLE OF t_pricing_report,
        l_row_cnt      TYPE i.
    * create the query string
    CONCATENATE
        'select A.SEQ,A.CONDTABLE,A.CONDNAME,A.VKORG,A.VTWEG,A.MATKL,A.MATNR,B.MTEXT,A.VKGRP,A.SGRPNAME,'
        'A.VKBUR,A.SOFFNAME,A.ZSALES,A.SCNTNAME,A.KUNNR,A.SCSTNAME,A.PRBATCH,A.INCO1,'
        'A.INCO2,A.DATAB,A.DATBI,A.KBETR,A.KONWA,A.KOSRT,B.MTART,B.GROES,B.VOLUM,B.EXTWG,B.WRKST,'
        'A.MXWRT,A.GKWRT,'
        'B.PATTERN,B.RIM,B.SERIES,B.SPDINDEX,B.LDINDX,B.MGROUP,B.APPLN,B.SDWALL,B.MGRPTXT'
        'FROM Z_PRICELIST A,Z_MATERIALVIEW B'
        'WHERE A.MANDT = ? AND'
              'B.MANDT = A.MANDT AND'
              'A.MATNR = B.MATNR AND'
              'A.KSCHL = ? AND'
              'A.CONDTABLE LIKE ? AND'
              'A.VKORG LIKE ? AND'
              'A.VTWEG LIKE ? AND'
              'A.MATKL >= ? AND A.MATKL <= ? AND'
              'A.MATNR >= ? AND A.MATNR <= ? AND'
              'A.INCO1 LIKE ? AND'
              'A.INCO2 LIKE ? AND'
              'A.ZSALES >= ? AND A.ZSALES <= ? AND'
              'A.KUNNR  >= ? AND A.KUNNR <= ? AND'
              'A.PRBATCH  >= ? AND A.PRBATCH <= ? AND'
              'A.VKBUR  >= ? AND A.VKBUR <= ? AND'
              'A.VKGRP  >= ? AND A.VKGRP <= ? AND'
              'B.WRKST  >= ? AND B.WRKST <= ? AND'
              'B.MTART  >= ? AND B.MTART <= ? AND'
              '? BETWEEN A.DATAB AND A.DATBI AND'
              'B.GROES LIKE ? AND'
              'B.LDINDX LIKE ? AND'
              'B.SPDINDEX LIKE ? AND'
              'B.RIM LIKE ? AND'
              'B.SERIES LIKE ? AND'
              'B.PATTERN LIKE ? AND'
              'B.MGROUP LIKE ?'
              'order by A.MATNR'
        INTO l_stmt SEPARATED BY space.                         "#EC NOTEXT
    * create a statement object
      l_stmt_ref = p_con_ref->create_statement( ).
    * bind input variables
      GET REFERENCE OF l_col1 INTO l_dref.
      l_stmt_ref->set_param( l_dref ).
    *binding other references here
      GET REFERENCE OF l_col33 INTO l_dref.
      l_stmt_ref->set_param( l_dref ).
    * set the input values and execute the query
      l_col1  = sy-mandt.
    *..Assigning values here
      l_col33 = p_mgroup.
    *  PERFORM trace_2 USING 'EXECUTE_QUERY' l_stmt l_col1 l_col2.
      l_res_ref = l_stmt_ref->execute_query( l_stmt ).
    * set output table
      GET REFERENCE OF l_itab INTO l_dref.
      l_res_ref->set_param_table( l_dref ).
    * get the complete result set
      l_row_cnt = l_res_ref->next_package( ).
    * display the contents of the output table
    *  PERFORM trace_next_package USING l_itab.
    *  PERFORM trace_result USING l_row_cnt 'rows fetched'.
      pricing_report[] = l_itab[].
      free l_itab.
    * don't forget to close the result set object in order to free
    * resources on the database
      l_res_ref->close( ).
    ENDFORM.                    "select_into_table
    *  FORM disconnect
    *  Disconnect from the given connection. In case of the default
    *  connection this can be omitted.
    FORM disconnect
      USING   p_con_ref TYPE REF TO cl_sql_connection
      RAISING cx_sql_exception.
      DATA: l_con_name TYPE dbcon-con_name.
      l_con_name = p_con_ref->get_con_name( ).
      CHECK l_con_name <> cl_sql_connection=>c_default_connection.
    *  PERFORM trace_0 USING 'CLOSE CONNECTION' l_con_name.
      p_con_ref->close( ).
    *  PERFORM trace_result USING l_con_name 'closed'.
    ENDFORM.                    "disconnect
    *  FORM handle_sql_exception
    *  Write appropriate error messages when a SQL exception has occured
    *  -->  P_SQLERR_REF  reference to a CX_SQL_EXCEPTION object
    FORM handle_sql_exception
      USING p_sqlerr_ref TYPE REF TO cx_sql_exception.
      FORMAT COLOR COL_NEGATIVE.
      IF p_sqlerr_ref->db_error = 'X'.
        WRITE: / 'SQL error occured:', p_sqlerr_ref->sql_code,
               / p_sqlerr_ref->sql_message.                     "#EC NOTEXT
      ELSE.
        WRITE:
          / 'Error from DBI (details in dev-trace):',
            p_sqlerr_ref->internal_error.                       "#EC NOTEXT
      ENDIF.
    ENDFORM.                    "handle_sql_exception

  • Native SQL to an external oracle database

    Hello experts,
         I like to read some data from an external oracle database with native sql statements.
    Which prerequisites are neccessary to do so?
    In detail: which customizing must be performed?
    Wich authorizations are necessary on the local SAP-system and on the oracle-site?
    Many thanks for your help!
             Best regards
                                Elmar

    first, you need the SAP database library for Oracle. on Windows, filename is dboraslib.dll
    then, you create a user ID on your external database
    then ,you configure table DBCON
    read:
    https://forums.sdn.sap.com/click.jspa?searchID=9272762&messageID=1193314
    https://forums.sdn.sap.com/click.jspa?searchID=9272762&messageID=2806510

  • Converting Native SQL to OPEN SQL

    Any inputs on how the following Native SQL can be converted to OPEN SQL.
    Especially self join of same table .
    EXEC SQL PERFORMING APPEND_ITAB.
        SELECT /+ ORDERED/
               A.VTYPE,          A.LIFNR,          G.MTNO,
               A.ASYTR,          A.DATAB,          A.DATBI,
               D.MAKTX,          F.NAME1,          G.COMP,
               C.PREF,           C.COMP,           E.MAKTX,
               C.QNTY,           C.UNIT,           B.MEINS,
               A.EKGRP,          A.SEQNO,          C.STGB,
               C.DATUV,          C.DATUB
          INTO :WA_MODULE-VTYPE, :WA_MODULE-LIFNR, :WA_MODULE-MATNR,
               :WA_MODULE-ASYTR, :WA_MODULE-DATAB, :WA_MODULE-DATBI,
               :WA_MODULE-MAKTX, :WA_MODULE-NAME1, :WA_SUB-UPGVC,
               :WA_SUB-PREF,     :WA_SUB-COMP,     :WA_SUB-MAKTX,
               :WA_SUB-QNTY,     :WA_SUB-UNIT,     :WA_SUB-MEINS,
               :WA_MODULE-EKGRP, :WA_MODULE-SEQNO, :WA_SUB-STGB,
               :WA_SUB-DATAB,    :WA_SUB-DATBI
          FROM ZTMM_ASSY_COST1 A, ZTBM_ABXDULDT G,
               ZTBM_ABXDULDT   C, MARA B,  MAKT D,  MAKT E, LFA1 F
         WHERE A.MANDT    =       :SY-MANDT
           AND A.VTYPE    BETWEEN :WA_VTYPE_F AND :WA_VTYPE_T
           AND A.MCODE    BETWEEN :WA_MCODE_F AND :WA_MCODE_T
           AND A.LIFNR    BETWEEN :WA_LIFNR_F AND :WA_LIFNR_T
           AND A.EKGRP    BETWEEN :WA_EKGRP_F AND :WA_EKGRP_T
           AND A.DATAB    <=      :P_DATUM
           AND A.DATBI    >=      :P_DATUM
           AND F.MANDT    =       A.MANDT
           AND F.LIFNR    =       A.LIFNR
           AND G.MANDT    =       A.MANDT
           AND G.MTNO     LIKE    CONCAT(CONCAT(A.VTYPE,A.MCODE),'%')
           AND G.MTNO     BETWEEN :WA_MATNR_F AND :WA_MATNR_T
           AND G.PLNT     =       :C_WERKS
           AND G.USAG     =       '2'
           AND G.ALTN     in      ('1','01')
           AND G.DATUV    <=      :P_DATUM
           AND G.DATUB    >=      :P_DATUM
           AND B.MANDT(+) =       G.MANDT
           AND B.MATNR(+) =       G.MTNO
           AND B.LVORM(+) =       ' '
           AND C.MANDT(+) =       G.MANDT
           AND C.MTNO(+)  =       G.COMP
           AND C.PLNT(+)  =       G.PLNT
           AND C.USAG(+)  =       '2'
           AND C.ALTN(+)  =       '01'
           AND C.DATUV(+) <=      :P_DATUM
           AND C.DATUB(+) >=      :P_DATUM
           AND D.MANDT(+) =       B.MANDT
           AND D.MATNR(+) =       B.MATNR
           AND D.SPRAS(+) =       :SY-LANGU
           AND E.MANDT(+) =       C.MANDT
           AND E.MATNR(+) =       C.COMP
           AND E.SPRAS(+) =       :SY-LANGU
         ORDER BY A.VTYPE, A.LIFNR, G.MTNO
      ENDEXEC.

    Then why don't you post the code you have. It would be a lot easier for us to improve that rather than try do redo what you have already done.
    Rob

  • Native SQL Performance Difference Between Hard-Coded Value and Parameter

    Hi,
    I have a native SQL (Oracle) query (fairly long & complex with a few sub-queries) that returns in under a second in both ODSI and using an external SQL tool. This query has a hard-coded value for a particular column, namely, a date column.
    When I modify the ODSI function signature so that I pass in a parameter and then replace the hard-coded value in the native SQL with the appropriate parameter binding notation (i.e. '?'), the query takes much longer (2-30 seconds). The duration of the query depends on how many records are actually returned, so it must be running a separate query for each of the results (i.e. the more results returned, the longer the query takes to return).
    What can I do to keep the duration of my ODSI query low while allowing for the parameter?

    OSDI plan with date parameter:
    <?xml version="1.0"?>
    <source ns="fn-bea" name="jdbc.wcb.fineos" kind="relational" tip="jdbc.wcb.fineos">
    <![CDATA[select codeid, description, FEE_CODE_DOC_TYPE, ismax, isovr
    from
    select distinct
    sd.codeid, sd.description,
    select count(*) from wcbapp.tolserviceset ss, wcbapp.RSERVICESRVCSETSERVICESETS sss, wcbapp.tolservicedefinition sd1 where
    sss.i_from = sd.i and
    sss.c_from = sd.c and
    sss.i_to = ss.i and
    sss.c_to = ss.c and
    sd1.codeid = sd.codeid and
    ss.name = 'FEEGROUP-MAX (MAXIMUM AMOUNT)'
    ) ISMAX,
    select count(*) from wcbapp.tolserviceset ss, wcbapp.RSERVICESRVCSETSERVICESETS sss, wcbapp.tolservicedefinition sd1 where
    sss.i_from = sd.i and
    sss.c_from = sd.c and
    sss.i_to = ss.i and
    sss.c_to = ss.c and
    sd1.codeid = sd.codeid and
    ss.name = 'FEEGROUP-OVR (Overrideable)'
    ISOVR,
    select count(*) from wcbapp.tolserviceset ss, wcbapp.RSERVICESRVCSETSERVICESETS sss, wcbapp.tolservicedefinition sd1 where
    sss.i_from = sd.i and
    sss.c_from = sd.c and
    sss.i_to = ss.i and
    sss.c_to = ss.c and
    sd1.codeid = sd.codeid and
    ss.name = 'FEEGROUP-INT (Internet Enterable)'
    ISINT
    ,trow.answerstr FEE_CODE_DOC_TYPE
    from wcbapp.tocorganisation o, wcbapp.tolpartydetails pd, wcbapp.tolserviceagrmtforprovider safp,
    wcbapp.tolserviceagreement sa, wcbapp.tolserviceagreementversion sav, wcbapp.rsrvchrgrsrvagrvrserviceagreem scg_sav,
    wcbapp.tolservicechargegroup scg, wcbapp.tolservicechargegroupversion scgv, wcbapp.tolserviceprovisionagreement spa,
    wcbapp.tolservicedefinition sd
    ,wcbapp.trow trow, wcbapp.tlookupversion tlookupversion, wcbapp.tlookup tlookup
    where
    trow.i_lkpver_rows = tlookupversion.i
    and trow.c_lkpver_rows = tlookupversion.c
    and tlookupversion.i_lookup_versions = tlookup.i
    and tlookupversion.c_lookup_versions = tlookup.c
    and sd.codeid = trow.minstr_1
    and sd.codeid = trow.maxstr_1
    and tlookup.name = 'FeeCodeToDocumentLookup' and
    spa.i_service_serviceratede = sd.i and
    spa.c_service_serviceratede = sd.c and
    spa.i_srchrgrv_serviceratede = scgv.i and
    spa.c_srchrgrv_serviceratede = scgv.c and
    scgv.i_srvchrgr_servicecharge = scg.i and
    scgv.c_srvchrgr_servicecharge = scg.c and
    scg.i = scg_sav.i_from and
    scg.c = scg_sav.c_from and
    scg_sav.i_to = sav.i and
    scg_sav.c_to = sav.c and
    sav.i_srvcagrm_serviceagreem = sa.i and
    sav.c_srvcagrm_serviceagreem = sa.c and
    sa.i = safp.i_srvcagrm_provider and
    sa.c = safp.c_srvcagrm_provider and
    safp.i_prtdtls_serviceagreem = pd.i and
    safp.c_prtdtls_serviceagreem = pd.c and
    pd.i_ocprty_party = o.i and
    pd.c_ocprty_party = o.c and
    ? between safp.effectivedate and safp.enddate and
    o.customerno = ? || ?
    order by sd.codeid
    where ISINT = 1]]>
    <variable name="__fparam0" kind="EXTERNAL">
    </variable>
    <variable name="__fparam1" kind="EXTERNAL">
    </variable>
    <variable name="__fparam2" kind="EXTERNAL">
    </variable>
    </source>
    OSDI plan with date constant:
    <?xml version="1.0"?>
    <source ns="fn-bea" name="jdbc.wcb.fineos" kind="relational" tip="jdbc.wcb.fineos">
    <![CDATA[select codeid, description, FEE_CODE_DOC_TYPE, ismax, isovr
    from
    select distinct
    sd.codeid, sd.description,
    select count(*) from wcbapp.tolserviceset ss, wcbapp.RSERVICESRVCSETSERVICESETS sss, wcbapp.tolservicedefinition sd1 where
    sss.i_from = sd.i and
    sss.c_from = sd.c and
    sss.i_to = ss.i and
    sss.c_to = ss.c and
    sd1.codeid = sd.codeid and
    ss.name = 'FEEGROUP-MAX (MAXIMUM AMOUNT)'
    ) ISMAX,
    select count(*) from wcbapp.tolserviceset ss, wcbapp.RSERVICESRVCSETSERVICESETS sss, wcbapp.tolservicedefinition sd1 where
    sss.i_from = sd.i and
    sss.c_from = sd.c and
    sss.i_to = ss.i and
    sss.c_to = ss.c and
    sd1.codeid = sd.codeid and
    ss.name = 'FEEGROUP-OVR (Overrideable)'
    ISOVR,
    select count(*) from wcbapp.tolserviceset ss, wcbapp.RSERVICESRVCSETSERVICESETS sss, wcbapp.tolservicedefinition sd1 where
    sss.i_from = sd.i and
    sss.c_from = sd.c and
    sss.i_to = ss.i and
    sss.c_to = ss.c and
    sd1.codeid = sd.codeid and
    ss.name = 'FEEGROUP-INT (Internet Enterable)'
    ISINT
    ,trow.answerstr FEE_CODE_DOC_TYPE
    from wcbapp.tocorganisation o, wcbapp.tolpartydetails pd, wcbapp.tolserviceagrmtforprovider safp,
    wcbapp.tolserviceagreement sa, wcbapp.tolserviceagreementversion sav, wcbapp.rsrvchrgrsrvagrvrserviceagreem scg_sav,
    wcbapp.tolservicechargegroup scg, wcbapp.tolservicechargegroupversion scgv, wcbapp.tolserviceprovisionagreement spa,
    wcbapp.tolservicedefinition sd
    ,wcbapp.trow trow, wcbapp.tlookupversion tlookupversion, wcbapp.tlookup tlookup
    where
    trow.i_lkpver_rows = tlookupversion.i
    and trow.c_lkpver_rows = tlookupversion.c
    and tlookupversion.i_lookup_versions = tlookup.i
    and tlookupversion.c_lookup_versions = tlookup.c
    and sd.codeid = trow.minstr_1
    and sd.codeid = trow.maxstr_1
    and tlookup.name = 'FeeCodeToDocumentLookup' and
    spa.i_service_serviceratede = sd.i and
    spa.c_service_serviceratede = sd.c and
    spa.i_srchrgrv_serviceratede = scgv.i and
    spa.c_srchrgrv_serviceratede = scgv.c and
    scgv.i_srvchrgr_servicecharge = scg.i and
    scgv.c_srvchrgr_servicecharge = scg.c and
    scg.i = scg_sav.i_from and
    scg.c = scg_sav.c_from and
    scg_sav.i_to = sav.i and
    scg_sav.c_to = sav.c and
    sav.i_srvcagrm_serviceagreem = sa.i and
    sav.c_srvcagrm_serviceagreem = sa.c and
    sa.i = safp.i_srvcagrm_provider and
    sa.c = safp.c_srvcagrm_provider and
    safp.i_prtdtls_serviceagreem = pd.i and
    safp.c_prtdtls_serviceagreem = pd.c and
    pd.i_ocprty_party = o.i and
    pd.c_ocprty_party = o.c and
    '01-MAY-11' between safp.effectivedate and safp.enddate and
    o.customerno = ? || ?
    order by sd.codeid
    where ISINT = 1]]>
    <variable name="__fparam0" kind="EXTERNAL">
    </variable>
    <variable name="__fparam1" kind="EXTERNAL">
    </variable>
    </source>
    ODSI Audit with date parameter:
    [Thu May 12 13:02:23 GMT-06:00 2011] Starting...
    Query compilation time: 0 ms
    Query evaluation time: 16142 ms
    Operation duration: 16189 ms
    Audit Event:
    common/application
    user: weblogic
    name: ClaimsDataspace
    server: AdminServer
    eventkind: evaluation
    query/cache/queryplan
    found: false
    type: XQUERY_PLAN_CACHE
    query/cache/queryplan
    type: XQUERY_PLAN_CACHE
    inserted: true
    query/performance
    compiletime: 0
    common/session/query/invocation
    time: Thu May 12 13:02:07 GMT-06:00 2011
    blocksize: 65536
    duration: 16001
    common/session/query/invocation
    time: Thu May 12 13:02:23 GMT-06:00 2011
    blocksize: 65536
    duration: 47
    common/session/query/invocation
    time: Thu May 12 13:02:23 GMT-06:00 2011
    blocksize: 65536
    duration: 46
    common/session/query/invocation
    time: Thu May 12 13:02:23 GMT-06:00 2011
    blocksize: 35779
    duration: 16
    query/wrappers/relational
    source: jdbc.wcb.fineos
    sql:
    select codeid, description, FEE_CODE_DOC_TYPE, ismax, isovr
    from
    select distinct
    sd.codeid, sd.description,
    select count(*) from wcbapp.tolserviceset ss, wcbapp.RSERVICESRVCSETSERVICESETS sss, wcbapp.tolservicedefinition sd1 where
    sss.i_from = sd.i and
    sss.c_from = sd.c and
    sss.i_to = ss.i and
    sss.c_to = ss.c and
    sd1.codeid = sd.codeid and
    ss.name = 'FEEGROUP-MAX (MAXIMUM AMOUNT)'
    ) ISMAX,
    select count(*) from wcbapp.tolserviceset ss, wcbapp.RSERVICESRVCSETSERVICESETS sss, wcbapp.tolservicedefinition sd1 where
    sss.i_from = sd.i and
    sss.c_from = sd.c and
    sss.i_to = ss.i and
    sss.c_to = ss.c and
    sd1.codeid = sd.codeid and
    ss.name = 'FEEGROUP-OVR (Overrideable)'
    ISOVR,
    select count(*) from wcbapp.tolserviceset ss, wcbapp.RSERVICESRVCSETSERVICESETS sss, wcbapp.tolservicedefinition sd1 where
    sss.i_from = sd.i and
    sss.c_from = sd.c and
    sss.i_to = ss.i and
    sss.c_to = ss.c and
    sd1.codeid = sd.codeid and
    ss.name = 'FEEGROUP-INT (Internet Enterable)'
    ISINT
    ,trow.answerstr FEE_CODE_DOC_TYPE
    from wcbapp.tocorganisation o, wcbapp.tolpartydetails pd, wcbapp.tolserviceagrmtforprovider safp,
    wcbapp.tolserviceagreement sa, wcbapp.tolserviceagreementversion sav, wcbapp.rsrvchrgrsrvagrvrserviceagreem scg_sav,
    wcbapp.tolservicechargegroup scg, wcbapp.tolservicechargegroupversion scgv, wcbapp.tolserviceprovisionagreement spa,
    wcbapp.tolservicedefinition sd
    ,wcbapp.trow trow, wcbapp.tlookupversion tlookupversion, wcbapp.tlookup tlookup
    where
    trow.i_lkpver_rows = tlookupversion.i
    and trow.c_lkpver_rows = tlookupversion.c
    and tlookupversion.i_lookup_versions = tlookup.i
    and tlookupversion.c_lookup_versions = tlookup.c
    and sd.codeid = trow.minstr_1
    and sd.codeid = trow.maxstr_1
    and tlookup.name = 'FeeCodeToDocumentLookup' and
    spa.i_service_serviceratede = sd.i and
    spa.c_service_serviceratede = sd.c and
    spa.i_srchrgrv_serviceratede = scgv.i and
    spa.c_srchrgrv_serviceratede = scgv.c and
    scgv.i_srvchrgr_servicecharge = scg.i and
    scgv.c_srvchrgr_servicecharge = scg.c and
    scg.i = scg_sav.i_from and
    scg.c = scg_sav.c_from and
    scg_sav.i_to = sav.i and
    scg_sav.c_to = sav.c and
    sav.i_srvcagrm_serviceagreem = sa.i and
    sav.c_srvcagrm_serviceagreem = sa.c and
    sa.i = safp.i_srvcagrm_provider and
    sa.c = safp.c_srvcagrm_provider and
    safp.i_prtdtls_serviceagreem = pd.i and
    safp.c_prtdtls_serviceagreem = pd.c and
    pd.i_ocprty_party = o.i and
    pd.c_ocprty_party = o.c and
    ? between safp.effectivedate and safp.enddate and
    o.customerno = ? || ?
    order by sd.codeid
    where ISINT = 1
    parameters:
    2011-05-01T00:00:00
    DOC
    007492
    time: 16048
    rows: 1967
    query/performance
    evaltime: 16142
    query/service
    result:
    *** removed due to length ***
    query/service
    function: getFeeCodeByCaregiverEffectiveDate1
    arity: 3
    dataservice: ld:org/wcb/claims/payment/FINEOS/physical/SQL.ds
    query:
    import schema namespace t1 = "http://www.test.com/claims/payment" at "ld:org/wcb/claims/payment/FINEOS/physical/schemas/SQL.xsd";
    declare namespace ns0="ld:org/wcb/claims/payment/FINEOS/physical/SQL";
    declare namespace ns1="http://www.w3.org/2001/XMLSchema";
    declare variable $__fparam0 as ns1:dateTime external;
    declare variable $__fparam1 as ns1:string external;
    declare variable $__fparam2 as ns1:string external;
    fn:subsequence(
    for $FeeCode3 in ns0:getFeeCodeByCaregiverEffectiveDate1($__fparam0,$__fparam1,$__fparam2)
         return
                   $FeeCode3
    ,1,5000)
    parameters:
    2011-05-01T00:00:00
    DOC
    007492
    common/time
    duration: 16189
    timestamp: Thu May 12 13:02:07 GMT-06:00 2011
    [Thu May 12 13:02:23 GMT-06:00 2011] End
    ODSI Audit with date constant:
    [Thu May 12 13:10:00 GMT-06:00 2011] Starting...
    Query compilation time: 0 ms
    Query evaluation time: 359 ms
    Operation duration: 375 ms
    Audit Event:
    common/application
    user: weblogic
    name: ClaimsDataspace
    server: AdminServer
    eventkind: evaluation
    query/cache/queryplan
    found: true
    type: XQUERY_PLAN_CACHE
    query/performance
    compiletime: 0
    common/session/query/invocation
    time: Thu May 12 13:10:00 GMT-06:00 2011
    blocksize: 59256
    duration: 359
    query/wrappers/relational
    source: jdbc.wcb.fineos
    sql:
    select codeid, description, FEE_CODE_DOC_TYPE, ismax, isovr
    from
    select distinct
    sd.codeid, sd.description,
    select count(*) from wcbapp.tolserviceset ss, wcbapp.RSERVICESRVCSETSERVICESETS sss, wcbapp.tolservicedefinition sd1 where
    sss.i_from = sd.i and
    sss.c_from = sd.c and
    sss.i_to = ss.i and
    sss.c_to = ss.c and
    sd1.codeid = sd.codeid and
    ss.name = 'FEEGROUP-MAX (MAXIMUM AMOUNT)'
    ) ISMAX,
    select count(*) from wcbapp.tolserviceset ss, wcbapp.RSERVICESRVCSETSERVICESETS sss, wcbapp.tolservicedefinition sd1 where
    sss.i_from = sd.i and
    sss.c_from = sd.c and
    sss.i_to = ss.i and
    sss.c_to = ss.c and
    sd1.codeid = sd.codeid and
    ss.name = 'FEEGROUP-OVR (Overrideable)'
    ISOVR,
    select count(*) from wcbapp.tolserviceset ss, wcbapp.RSERVICESRVCSETSERVICESETS sss, wcbapp.tolservicedefinition sd1 where
    sss.i_from = sd.i and
    sss.c_from = sd.c and
    sss.i_to = ss.i and
    sss.c_to = ss.c and
    sd1.codeid = sd.codeid and
    ss.name = 'FEEGROUP-INT (Internet Enterable)'
    ISINT
    ,trow.answerstr FEE_CODE_DOC_TYPE
    from wcbapp.tocorganisation o, wcbapp.tolpartydetails pd, wcbapp.tolserviceagrmtforprovider safp,
    wcbapp.tolserviceagreement sa, wcbapp.tolserviceagreementversion sav, wcbapp.rsrvchrgrsrvagrvrserviceagreem scg_sav,
    wcbapp.tolservicechargegroup scg, wcbapp.tolservicechargegroupversion scgv, wcbapp.tolserviceprovisionagreement spa,
    wcbapp.tolservicedefinition sd
    ,wcbapp.trow trow, wcbapp.tlookupversion tlookupversion, wcbapp.tlookup tlookup
    where
    trow.i_lkpver_rows = tlookupversion.i
    and trow.c_lkpver_rows = tlookupversion.c
    and tlookupversion.i_lookup_versions = tlookup.i
    and tlookupversion.c_lookup_versions = tlookup.c
    and sd.codeid = trow.minstr_1
    and sd.codeid = trow.maxstr_1
    and tlookup.name = 'FeeCodeToDocumentLookup' and
    spa.i_service_serviceratede = sd.i and
    spa.c_service_serviceratede = sd.c and
    spa.i_srchrgrv_serviceratede = scgv.i and
    spa.c_srchrgrv_serviceratede = scgv.c and
    scgv.i_srvchrgr_servicecharge = scg.i and
    scgv.c_srvchrgr_servicecharge = scg.c and
    scg.i = scg_sav.i_from and
    scg.c = scg_sav.c_from and
    scg_sav.i_to = sav.i and
    scg_sav.c_to = sav.c and
    sav.i_srvcagrm_serviceagreem = sa.i and
    sav.c_srvcagrm_serviceagreem = sa.c and
    sa.i = safp.i_srvcagrm_provider and
    sa.c = safp.c_srvcagrm_provider and
    safp.i_prtdtls_serviceagreem = pd.i and
    safp.c_prtdtls_serviceagreem = pd.c and
    pd.i_ocprty_party = o.i and
    pd.c_ocprty_party = o.c and
    '01-MAY-11' between safp.effectivedate and safp.enddate and
    o.customerno = ? || ?
    order by sd.codeid
    where ISINT = 1
    parameters:
    DOC
    007492
    time: 344
    rows: 500
    query/performance
    evaltime: 359
    query/service
    result:
    *** removed due to length ***
    query/service
    function: getFeeCodeByCaregiverEffectiveDate1
    arity: 2
    dataservice: ld:org/wcb/claims/payment/FINEOS/physical/SQL.ds
    query:
    import schema namespace t1 = "http://www.test.com/claims/payment" at "ld:org/wcb/claims/payment/FINEOS/physical/schemas/SQL.xsd";
    declare namespace ns0="ld:org/wcb/claims/payment/FINEOS/physical/SQL";
    declare namespace ns1="http://www.w3.org/2001/XMLSchema";
    declare variable $__fparam0 as ns1:string external;
    declare variable $__fparam1 as ns1:string external;
    fn:subsequence(
    for $FeeCode3 in ns0:getFeeCodeByCaregiverEffectiveDate1($__fparam0,$__fparam1)
         return
                   $FeeCode3
    ,1,500)
    parameters:
    DOC
    007492
    common/time
    duration: 375
    timestamp: Thu May 12 13:10:00 GMT-06:00 2011
    [Thu May 12 13:10:00 GMT-06:00 2011] End
    ------------------------------------------------------------------------

  • Open & Native SQL

    Hai all !
      Can anybody give me the exact Difference between Open SQL & Native SQL.
    Thanks in Advance,
    Swapna.

    Hii!
       Open SQL is basically SAP specific Structured Query language.Open SQL consists of a set of ABAP statements that perform operations on the central database in the R/3 System. The results of the operations and any error messages are independent of the database system in use. Open SQL thus provides a uniform syntax and semantics for all of the database systems supported by SAP. ABAP programs that only use Open SQL statements will work in any R/3 System, regardless of the database system in use. Open SQL statements can only work with database tables that have been created in the ABAP Dictionary.
    Native SQL is basically a database specific language.
    Open SQL allows you to access database tables declared in the ABAP Dictionary regardless of the database platform that you R/3 System is using. Native SQL allows you to use database-specific SQL statements in an ABAP program. This means that you can use database tables that are not administered by the ABAP Dictionary, and therefore integrate data that is not part of the R/3 System.
    As a rule, an ABAP program containing database-specific SQL statements will not run under different database systems. If your program will be used on more than one database platform, only use Open SQL statements.
    To use a Native SQL statement, you must precede it with the EXEC SQL statement, and follow it with the ENDEXEC statement as follows:
    EXEC SQL [PERFORMING <form>].
      <Native SQL statement>
    ENDEXEC.

  • Open an native sql

    1) what is open sql an wat is native sql an wt is the diference between these to.....

    Hi Satish,
    The difference is:
    OPEN SQL - Open SQL consists of a set of ABAP statements that perform operations on the central database in the R/3 System. The results of the operations and any error messages are independent of the database system in use. Open SQL thus provides a uniform syntax and semantics for all of the database systems supported by SAP. ABAP programs that only use Open SQL statements will work in any R/3 System, regardless of the database system in use. Open SQL statements can only work with database tables that have been created in the ABAP Dictionary.
    NATIVE SQL - Open SQL allows you to access database tables declared in the ABAP Dictionary regardless of the database platform that you R/3 System is using. Native SQL allows you to use database-specific SQL statements in an ABAP program. This means that you can use database tables that are not administered by the ABAP Dictionary, and therefore integrate data that is not part of the R/3 System.
    Plz Reward if useful,
    Mahi.

  • Performance for join 9 custom table with native SQL ?

    Hi Expert,
    I need your opinion regarding performance to join 9 tables with native sql. Recently i have to tunning some customize extraction cost  report. This report extract about 10 million cost of material everyday.
    The current program actually, try to populate the condition data and insert into customize table and join all the table to get data using native sql.
    SELECT /*+ ordered use_hash(mst,pg,rg,ps,rs,dpg,drg,dps,drs) */
                mst.werks, ....................................
    FROM
                sapsr3.zab_info mst,
                sapsr3.zab_pc pg,
                sapsr3.zab_rc rg,
                sapsr3.zab_pc ps,
                sapsr3.zab_rc rs,
                sapsr3.zab_g_pc dpg,
                sapsr3.zab_g_rc drg,
                sapsr3.zab_s_pc dps,
                sapsr3.zab_s_rc drs
            WHERE mst.zseq_no = :p_rep_run_id
            AND mst.werks = :p_werks
            AND mst.mandt = rg.mandt(+)
            AND mst.ekorg = rg.ekorg(+)
            AND mst.lifnr = rg.lifnr(+)
            AND mst.matnr = rg.matnr(+)
            ...............................................   unitl all table (9 tables)
            AND ps.mandt = dps.mandt(+)
            AND ps.knumh = dps.knumh(+)
            AND ps.zseq_no = dps.zseq_no(+)
            AND COALESCE (dps.kbetr, drs.kbetr, dpg.kbetr, drg.kbetr) <> 0
    It seems the query ask for database to using hashed table. would that be it will burden the database ? and impacted to others sap process ?
    Please advise
    Thank You and Best Regards

    you can only argue coming from measurements and that is not the case.
    Coming from the code, I see only that you do not understand it at all, so better leave it as it is. It is not a hash table, but a hash join on these table.

  • TIME_OUT in SAP when accessing external Oracle table thru native SQL

    Hi,
    I have a problem in one of my native SQL statement. It takes a long time accessing the table considering that the number of records to be retrieved is only small.
    Something happened on the Oracle system. But, stilll to be confirmed. Before, there wasn't any issue. Looking further, I found that when the value in the where clause equated is a literal (meaning the value is not declared in DATA or CONSTANTS in the ABAP Program)
    Example
    1.
    EXEC.
    WHERE FIELD = '1'
    ENDEXEC.
    instead of
    2.
    CONSTANTS: c_1 value '1'.
    EXEC.
    WHERE FIELD = c_1
    ENDEXEC.
    i found that when the way of coding is same as Example 1, a time-out error occurs. But when in Example 2, no issue.
    Can someone explain this? is their something that could affect SAP with respect to Oracle configuration?
    Thanks!

    I wonder if you could share the outline of your code to access an external oracle database.   I've just been given the assignment to do just that, but don't know where to start.
    thx,
    Mike DeGuire

  • TIME_OUT when accessing Oracle table from SAP using native SQL

    Hi,
    I have a problem in one of my native SQL statement. It takes a long time accessing the table considering that the number of records to be retrieved is only small.
    Something happened on the Oracle system. But, stilll to be confirmed. Looking further at the issue, it seems that when the value in the where clause equated is a literal (meaning the value is not declared in DATA or CONSTANTS in the ABAP Program)
    Example
    1.
    EXEC.
    WHERE FIELD = '1'
    ENDEXEC.
    instead of
    2.
    CONSTANTS: c_1 value '1'.
    EXEC.
    WHERE FIELD = c_1
    ENDEXEC.
    i found that when the way of coding is same as Example 1, a time-out error occurs. But when in Example 2, no issue.
    Can someone explain this?
    Thanks!

    Repetitively asking the same question again and again is against the forum rules.
    Please post an explain of the SQL statement on the remote machine.
    Markus

Maybe you are looking for