<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Poor query performance when using date range in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/poor-query-performance-when-using-date-range/m-p/7570220#M1565339</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the reason for the observed is fairly simple. Your filter condition applys a DB-funtion to a DB column,&lt;/P&gt;&lt;P&gt;which means all retrieved data needs to be converted by the function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So in writing the  query, the comparrison would be&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where&lt;/P&gt;&lt;P&gt;  CHAR_DB_FIELD = to_char_conversion( number_value ) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;which is very good, because the conversion is only done once, against&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where&lt;/P&gt;&lt;P&gt;  to_number_conversion(CHAR_DB_FIELD) = number_value &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;which is very bad, because the conversion needs to be applied against ALL retrieved records.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But the VERY question is: Why do you get SQL Statements without bind variables ?&lt;/P&gt;&lt;P&gt;You should get statements wit :A0 , :A1 , ... and so on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are options to force the kernel to generate such statements to be able to make use of histograms.&lt;/P&gt;&lt;P&gt;Do you have such parameters in place?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Volker&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 26 Jan 2011 18:04:37 GMT</pubDate>
    <dc:creator>volker_borowski2</dc:creator>
    <dc:date>2011-01-26T18:04:37Z</dc:date>
    <item>
      <title>Poor query performance when using date range</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/poor-query-performance-when-using-date-range/m-p/7570219#M1565338</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We have the following ABAP code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select sptag werks vkorg vtweg spart kunnr matnr periv volum_01 voleh&lt;/P&gt;&lt;P&gt;      into table tab_aux&lt;/P&gt;&lt;P&gt;      from s911&lt;/P&gt;&lt;P&gt;      where vkorg in c_vkorg&lt;/P&gt;&lt;P&gt;        and werks in c_werks&lt;/P&gt;&lt;P&gt;        and sptag in c_sptag&lt;/P&gt;&lt;P&gt;        and matnr in c_matnr&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;that is translated to the following Oracle query:&lt;/P&gt;&lt;P&gt;SELECT &lt;/P&gt;&lt;P&gt;"SPTAG" , "WERKS" , "VKORG" , "VTWEG" , "SPART" , "KUNNR" , "MATNR" , "PERIV" , "VOLUM_01" ,"VOLEH" FROM SAPR3."S911" WHERE "MANDT" = '003' AND "VKORG" = 'D004' AND "SPTAG" BETWEEN 20101201 AND 20101231 AND "MATNR" BETWEEN 000000000100000000 AND 000000000999999999;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Because the field SPTAG is not enclosed by apostropher, the oracle query has a very bad performance. Below the execution plans and its costs, with and without the apostrophes. Please help me understanding why I am getting this behaviour.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;##WITH APOSTROPHES&lt;/P&gt;&lt;P&gt;SQL&amp;gt; EXPLAIN PLAN FOR&lt;/P&gt;&lt;P&gt;  2  SELECT&lt;/P&gt;&lt;P&gt;  3  "SPTAG" , "WERKS" , "VKORG" , "VTWEG" , "SPART" , "KUNNR" , "MATNR" , "PERIV" , "VOLUM_01" ,"VOLEH" FROM SAPR3."S911" WHERE "MANDT" = '003' AND "VKORG" = 'D004' AND "SPTAG" BETWEEN '20101201' AND '20101231' AND "MATNR" BETWEEN '000000000100000000' AND '000000000999999999';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Explained.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SQL&amp;gt; SELECT PLAN_TABLE_OUTPUT FROM TABLE(DBMS_XPLAN.DISPLAY());&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PLAN_TABLE_OUTPUT&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------------------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------------------" /&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Id&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Operation&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Name&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Rows&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Bytes&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Cost (%CPU)&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------------------" /&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;0&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;SELECT STATEMENT&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;932&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;62444&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;150   (1)&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; 1&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;TABLE ACCESS BY INDEX ROWID&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;S911&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;932&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;62444&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;149   (0)&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; 2&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;INDEX RANGE SCAN&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;S911~VAC&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;55M&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;5   (0)&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Predicate Information (identified by operation id):&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PLAN_TABLE_OUTPUT&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------------------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   1 - filter("VKORG"='D004' AND "SPTAG"&amp;gt;='20101201' AND&lt;/P&gt;&lt;P&gt;              "SPTAG"&amp;lt;='20101231')&lt;/P&gt;&lt;P&gt;   2 - access("MANDT"='003' AND "MATNR"&amp;gt;='000000000100000000' AND&lt;/P&gt;&lt;P&gt;              "MATNR"&amp;lt;='000000000999999999')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;##WITHOUT APOSTROPHES&lt;/P&gt;&lt;P&gt;SQL&amp;gt; EXPLAIN PLAN FOR&lt;/P&gt;&lt;P&gt;  2  SELECT&lt;/P&gt;&lt;P&gt;  3  "SPTAG" , "WERKS" , "VKORG" , "VTWEG" , "SPART" , "KUNNR" , "MATNR" , "PERIV" , "VOLUM_01" ,"VOLEH" FROM SAPR3."S911" WHERE "MANDT" = '003' AND "VKORG" = 'D004' AND "SPTAG" BETWEEN 20101201 AND 20101231 AND "MATNR" BETWEEN '000000000100000000' AND '000000000999999999';&lt;/P&gt;&lt;P&gt;SELECT PLAN_TABLE_OUTPUT FROM TABLE(DBMS_XPLAN.DISPLAY());&lt;/P&gt;&lt;P&gt;Explained.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SQL&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PLAN_TABLE_OUTPUT&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------------------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------------------" /&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Id&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Operation&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Name&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Rows&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Bytes&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Cost (%CPU)&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------------------" /&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;0&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;SELECT STATEMENT&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;2334&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;152K&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;150   (1)&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; 1&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;TABLE ACCESS BY INDEX ROWID&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;S911&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;2334&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;152K&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;149   (0)&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; 2&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;INDEX RANGE SCAN&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;S911~VAC&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;55M&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;5   (0)&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Predicate Information (identified by operation id):&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PLAN_TABLE_OUTPUT&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------------------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   1 - filter("VKORG"='D004' AND TO_NUMBER("SPTAG")&amp;gt;=20101201 AND&lt;/P&gt;&lt;P&gt;              TO_NUMBER("SPTAG")&amp;lt;=20101231)&lt;/P&gt;&lt;P&gt;   2 - access("MANDT"='003' AND "MATNR"&amp;gt;='000000000100000000' AND&lt;/P&gt;&lt;P&gt;              "MATNR"&amp;lt;='000000000999999999')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Daniel G.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jan 2011 00:47:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/poor-query-performance-when-using-date-range/m-p/7570219#M1565338</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-01-26T00:47:46Z</dc:date>
    </item>
    <item>
      <title>Re: Poor query performance when using date range</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/poor-query-performance-when-using-date-range/m-p/7570220#M1565339</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the reason for the observed is fairly simple. Your filter condition applys a DB-funtion to a DB column,&lt;/P&gt;&lt;P&gt;which means all retrieved data needs to be converted by the function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So in writing the  query, the comparrison would be&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where&lt;/P&gt;&lt;P&gt;  CHAR_DB_FIELD = to_char_conversion( number_value ) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;which is very good, because the conversion is only done once, against&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where&lt;/P&gt;&lt;P&gt;  to_number_conversion(CHAR_DB_FIELD) = number_value &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;which is very bad, because the conversion needs to be applied against ALL retrieved records.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But the VERY question is: Why do you get SQL Statements without bind variables ?&lt;/P&gt;&lt;P&gt;You should get statements wit :A0 , :A1 , ... and so on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are options to force the kernel to generate such statements to be able to make use of histograms.&lt;/P&gt;&lt;P&gt;Do you have such parameters in place?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Volker&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jan 2011 18:04:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/poor-query-performance-when-using-date-range/m-p/7570220#M1565339</guid>
      <dc:creator>volker_borowski2</dc:creator>
      <dc:date>2011-01-26T18:04:37Z</dc:date>
    </item>
    <item>
      <title>Re: Poor query performance when using date range</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/poor-query-performance-when-using-date-range/m-p/7570221#M1565340</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Volker Borowski,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Those execution plans were retrieved directly from the Oracle. In ABAP the queries are generated with bind variables. I meant to ask why is the conversion from opensql (ABAP) to the oracle SQL done without enclosing the char variables with apostrophes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Daniel Garrido&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jan 2011 18:14:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/poor-query-performance-when-using-date-range/m-p/7570221#M1565340</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-01-26T18:14:15Z</dc:date>
    </item>
    <item>
      <title>Re: Poor query performance when using date range</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/poor-query-performance-when-using-date-range/m-p/7570222#M1565341</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;additionally to Volker's comments:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;how is c_sptag defined? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;obviously it is stored as varchar at the database, since it is not converted when you compare it with strings&lt;/P&gt;&lt;P&gt;and not as a number since it is converted when you compare it with numbers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Make sure to use the same data types.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;e.g. define c_sptag as a range for s911-sptag....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hermann&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jan 2011 18:24:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/poor-query-performance-when-using-date-range/m-p/7570222#M1565341</guid>
      <dc:creator>HermannGahm</dc:creator>
      <dc:date>2011-01-26T18:24:29Z</dc:date>
    </item>
    <item>
      <title>Re: Poor query performance when using date range</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/poor-query-performance-when-using-date-range/m-p/7570223#M1565342</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so what is the plan for the statement with bind variables like &lt;/P&gt;&lt;P&gt;(get it from ST05 with entering the statement with variables).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The ST05 output from the trace with variables filled in is actually not the one for which the plan is generated.&lt;/P&gt;&lt;P&gt;The filled in values are just for better reading of the trace.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the statement parsed (the one that is responsible for the plan) is actually the one with variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Get some of the DB-stats as well please.&lt;/P&gt;&lt;P&gt;Personally I always like to have&lt;/P&gt;&lt;P&gt;- # of blocks in table&lt;/P&gt;&lt;P&gt;- # of rows in table, &lt;/P&gt;&lt;P&gt;- name of fields in Index(es)&lt;/P&gt;&lt;P&gt;- number of distinct keys from all columns in where clause&lt;/P&gt;&lt;P&gt;- level(blevel) of indexes involved&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We'll see later what else might be needed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Volker&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jan 2011 19:42:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/poor-query-performance-when-using-date-range/m-p/7570223#M1565342</guid>
      <dc:creator>volker_borowski2</dc:creator>
      <dc:date>2011-01-26T19:42:54Z</dc:date>
    </item>
    <item>
      <title>Re: Poor query performance when using date range</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/poor-query-performance-when-using-date-range/m-p/7570224#M1565343</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Hermann,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Answering your question, c_sptag is defined the following way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: dt_range type range of s911-sptag with header line.&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;perform f_perio_data tables:i_sptag ix_sptag.&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Form  F_PERIO_DATA&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form f_perio_data tables: range structure dt_range&lt;/P&gt;&lt;P&gt;                          x_range structure per_range.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  data: dia_ini type s911-sptag.&lt;/P&gt;&lt;P&gt;  data: dia_fim type s911-sptag.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  refresh range.&lt;/P&gt;&lt;P&gt;  clear range.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  loop at x_range.&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;    dia_ini(6) = x_range-low.&lt;/P&gt;&lt;P&gt;    dia_ini+6(2) = '01'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    dia_fim&lt;EM&gt;4(2) = dia_ini&lt;/EM&gt;4(2) + 1.&lt;/P&gt;&lt;P&gt;    if dia_fim+4(2) = '13'.&lt;/P&gt;&lt;P&gt;      dia_fim+4(2) = '01'.&lt;/P&gt;&lt;P&gt;      dia_fim&lt;EM&gt;0(4) = dia_ini&lt;/EM&gt;0(4) + 1.&lt;/P&gt;&lt;P&gt;    else.&lt;/P&gt;&lt;P&gt;      dia_fim&lt;EM&gt;0(4) = dia_ini&lt;/EM&gt;0(4).&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    dia_fim+6(2) = '01'.&lt;/P&gt;&lt;P&gt;    dia_fim = dia_fim - 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    range-low = dia_ini.&lt;/P&gt;&lt;P&gt;    range-high = dia_fim.&lt;/P&gt;&lt;P&gt;    range-sign = 'I'.&lt;/P&gt;&lt;P&gt;    range-option = 'BT'.&lt;/P&gt;&lt;P&gt;    append range.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  endloop.&lt;/P&gt;&lt;P&gt;endform.                    " F_PERIO_DATA&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jan 2011 23:52:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/poor-query-performance-when-using-date-range/m-p/7570224#M1565343</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-01-26T23:52:33Z</dc:date>
    </item>
    <item>
      <title>Re: Poor query performance when using date range</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/poor-query-performance-when-using-date-range/m-p/7570225#M1565344</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Volker,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Answering your question, regarding the explain from ST05. As a quick work around I created an index (S911~Z9), but still I'd like to solve this issue without this extra index, as primary index would work ok, as long as date was correctly sent to oracle as string and not as number.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT                                                                          &lt;/P&gt;&lt;P&gt;  "SPTAG" , "WERKS" , "VKORG" , "VTWEG" , "SPART" , "KUNNR" , "MATNR" ,         &lt;/P&gt;&lt;P&gt;  "PERIV" , "VOLUM_01" , "VOLEH"                                                &lt;/P&gt;&lt;P&gt;FROM                                                                            &lt;/P&gt;&lt;P&gt;  "S911"                                                                        &lt;/P&gt;&lt;P&gt;WHERE                                                                           &lt;/P&gt;&lt;P&gt;  "MANDT" = :A0 AND "VKORG" = :A1 AND "SPTAG" BETWEEN :A2 AND :A3 AND "MATNR"   &lt;/P&gt;&lt;P&gt;  BETWEEN :A4 AND :A5                                                           &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A0(CH,3)  = 003               &lt;/P&gt;&lt;P&gt;A1(CH,4)  = D004              &lt;/P&gt;&lt;P&gt;A2(NU,8)  = 20101201  (NU means number correct?)        &lt;/P&gt;&lt;P&gt;A3(NU,8)  = 20101231          &lt;/P&gt;&lt;P&gt;A4(CH,18) = 000000000100000000&lt;/P&gt;&lt;P&gt;A5(CH,18) = 000000000999999999&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT STATEMENT ( Estimated Costs = 10 , Estimated #Rows = 6 )                                                               &lt;/P&gt;&lt;P&gt;    5  3 FILTER                                                &lt;/P&gt;&lt;P&gt;         Filter Predicates                                                                                &lt;/P&gt;&lt;P&gt;5  2 TABLE ACCESS BY INDEX ROWID S911                  &lt;/P&gt;&lt;P&gt;             ( Estim. Costs = 10 , Estim. #Rows = 6 )          &lt;/P&gt;&lt;P&gt;             Estim. CPU-Costs = 247.566 Estim. IO-Costs = 10                                                                                &lt;/P&gt;&lt;P&gt;1 INDEX RANGE SCAN S911~Z9                      &lt;/P&gt;&lt;P&gt;                 ( Estim. Costs = 7 , Estim. #Rows = 20 )      &lt;/P&gt;&lt;P&gt;                 Search Columns: 4                             &lt;/P&gt;&lt;P&gt;                 Estim. CPU-Costs = 223.202 Estim. IO-Costs = 7&lt;/P&gt;&lt;P&gt;                 Access Predicates Filter Predicates           &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The table originally includes the following indexes:&lt;/P&gt;&lt;P&gt;###S911~0&lt;/P&gt;&lt;P&gt;MANDT&lt;/P&gt;&lt;P&gt;SSOUR&lt;/P&gt;&lt;P&gt;VRSIO&lt;/P&gt;&lt;P&gt;SPMON&lt;/P&gt;&lt;P&gt;SPTAG&lt;/P&gt;&lt;P&gt;SPWOC&lt;/P&gt;&lt;P&gt;SPBUP&lt;/P&gt;&lt;P&gt;VKORG&lt;/P&gt;&lt;P&gt;VTWEG&lt;/P&gt;&lt;P&gt;SPART&lt;/P&gt;&lt;P&gt;VKBUR&lt;/P&gt;&lt;P&gt;VKGRP&lt;/P&gt;&lt;P&gt;KONDA&lt;/P&gt;&lt;P&gt;KUNNR&lt;/P&gt;&lt;P&gt;WERKS&lt;/P&gt;&lt;P&gt;MATNR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;###S911~VAC&lt;/P&gt;&lt;P&gt;MANDT&lt;/P&gt;&lt;P&gt;MATNR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Number of entries: 61.303.517&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DISTINCT VKORG: 65&lt;/P&gt;&lt;P&gt;DISTINCT SPTAG: 3107&lt;/P&gt;&lt;P&gt;DISTINCT MATNR: 2939&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Jan 2011 00:29:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/poor-query-performance-when-using-date-range/m-p/7570225#M1565344</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-01-27T00:29:42Z</dc:date>
    </item>
    <item>
      <title>Re: Poor query performance when using date range</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/poor-query-performance-when-using-date-range/m-p/7570226#M1565345</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;did you create a function based index? How does your index look like?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rigth now i find it quite confusing that we see this conversion...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hermann&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Jan 2011 07:30:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/poor-query-performance-when-using-date-range/m-p/7570226#M1565345</guid>
      <dc:creator>HermannGahm</dc:creator>
      <dc:date>2011-01-27T07:30:18Z</dc:date>
    </item>
    <item>
      <title>Re: Poor query performance when using date range</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/poor-query-performance-when-using-date-range/m-p/7570227#M1565346</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No, the existing indexes are the standard ones. No function based index has been created.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So it's not normal that the ABAP type DATS is converted to number oracle type?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Daniel Garrido&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Jan 2011 09:32:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/poor-query-performance-when-using-date-range/m-p/7570227#M1565346</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-01-27T09:32:03Z</dc:date>
    </item>
    <item>
      <title>Re: Poor query performance when using date range</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/poor-query-performance-when-using-date-range/m-p/7570228#M1565347</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello again,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;no, it is not normal, but I doubt that it is done that way. I think it is only displayed that way in ST05.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The plan is parsed for bind variables and the corresponding plan should show no function being applied in the filter.&lt;/P&gt;&lt;P&gt;Due to lack of the corresponding S911 tabel I got myself a standard Table with DATS and the ST05 EXPLAIN compiles to:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from TPCDATE where to_date = :A1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Filter Predicates&lt;/P&gt;&lt;P&gt; "TO_DATE"=:A1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So no "to_char" at all. The thesis is, that the missing quotes are only applied to the ST05 display because&lt;/P&gt;&lt;P&gt;of the NUMC format of the DATS datatype, which is in fact VARCHAR 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For your given condition and the structure so far, I think the PK is useles for a good access.&lt;/P&gt;&lt;P&gt;MATNR with that range as a qualifier is missleading for the optimizer as it is unselective.&lt;/P&gt;&lt;P&gt;Try to ommit it completely.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fill in your values into an SE16 selection and SQL Trace the SE16 call with the values.&lt;/P&gt;&lt;P&gt;This will have more information than the transformed statement for a direct Oracle Explain.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I assume you'll see a range scan on PK with only MANDT beinig used for access and with this&lt;/P&gt;&lt;P&gt;numer of rows it is worse than a full table scan. I think you might get no success without an additional index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What type of access do you think will perform good on the PK as long as you have unqualified columns&lt;/P&gt;&lt;P&gt;between MANDT and your first selective column. I even think a SKIP SCAN will do no good for this access.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Volker&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Jan 2011 17:48:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/poor-query-performance-when-using-date-range/m-p/7570228#M1565347</guid>
      <dc:creator>volker_borowski2</dc:creator>
      <dc:date>2011-01-27T17:48:50Z</dc:date>
    </item>
  </channel>
</rss>

