<?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: SQL performance in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance/m-p/1089850#M100374</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Amit Mittal&lt;/P&gt;&lt;P&gt;     Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 27 Dec 2005 11:19:26 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2005-12-27T11:19:26Z</dc:date>
    <item>
      <title>SQL performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance/m-p/1089843#M100367</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; A: SELECT vbeln parvw kunnr&lt;/P&gt;&lt;P&gt;    INTO TABLE gt_vbpa&lt;/P&gt;&lt;P&gt;    FROM vbpa&lt;/P&gt;&lt;P&gt;    FOR  ALL ENTRIES IN gt_vbak&lt;/P&gt;&lt;P&gt;    WHERE (&amp;lt;b&amp;gt; vbeln = gt_vbak-vbeln AND parvw = 'AG')&lt;/P&gt;&lt;P&gt;           or ( vbeln = gt_vbak-vbeln and parvw = RE&amp;lt;/b&amp;gt; )&lt;/P&gt;&lt;P&gt;  B:  &lt;/P&gt;&lt;P&gt;    SELECT vbeln parvw kunnr&lt;/P&gt;&lt;P&gt;    INTO TABLE gt_vbpa&lt;/P&gt;&lt;P&gt;    FROM vbpa&lt;/P&gt;&lt;P&gt;    FOR  ALL ENTRIES IN gt_vbak&lt;/P&gt;&lt;P&gt;    WHERE &amp;lt;b&amp;gt;vbeln = gt_vbak-vbeln AND &lt;/P&gt;&lt;P&gt;          (parvw = 'AG'  or   parvw = 'RE' )&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have two problems:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. TO the two SQLs , Do i need create index including vbeln and  parvw for best performance, why?.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Provided i have created a index including vbeln and  parvw .  What's difference between A and B ? why ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Dec 2005 02:07:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance/m-p/1089843#M100367</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-27T02:07:55Z</dc:date>
    </item>
    <item>
      <title>Re: SQL performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance/m-p/1089844#M100368</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;IF you have index including vbeln and parvw  the first statement is better than second. Because first statement will use that index(internally) not the second.In the first statment all the fields of the search criteria are part of the index.&lt;/P&gt;&lt;P&gt;Dont forget to put check gt_vbak[] is initial statement before select statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Dec 2005 02:30:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance/m-p/1089844#M100368</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-27T02:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: SQL performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance/m-p/1089845#M100369</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;VBPA table has the following keys: VBELN, POSNR and PARVW and the order of the key is&lt;/P&gt;&lt;P&gt;1- VBELN&lt;/P&gt;&lt;P&gt;2- POSNR&lt;/P&gt;&lt;P&gt;3- PARVW&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So if you has to read this table for these key I think you don't need to create an index.&lt;/P&gt;&lt;P&gt;Infact if you read this table using some of the key you'll use the primary index.&lt;/P&gt;&lt;P&gt;The primary index is index created by default with key field, so if you read VBPA using:&lt;/P&gt;&lt;P&gt;- VBELN, POSNR and PARVW&lt;/P&gt;&lt;P&gt;- VBELN, PSONR&lt;/P&gt;&lt;P&gt;- VBELN &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you'll use the primary index, because your reading of that table is always based on order of the keys&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But if you read VBAP using: VBELN and PRVW you won't the primary index because you don't respect the order of the key is build.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So you could do this reading:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT vbeln parvw kunnr INTO TABLE gt_vbpa&lt;/P&gt;&lt;P&gt;FROM vbpa&lt;/P&gt;&lt;P&gt;FOR ALL ENTRIES IN gt_vbak&lt;/P&gt;&lt;P&gt;WHERE vbeln = gt_vbak-vbeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DELETE gt_vbpa WHERE ( parvw &amp;lt;&amp;gt; 'AG' AND&lt;/P&gt;&lt;P&gt;                       PARVW &amp;lt;&amp;gt; 'RE' ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have created an index for VBELN and PARVW, you always read VBPA with only those two fields to use that index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Remember each index want a certain space on server, because every time it inserts a new record in VBPA, it'll insert a new record in the index. So you should create an index only if you really need it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your case I thin you can read the table using only VBELN and then delete the record where partner is not equal to AG and RE, you should have a good performance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: max bianchi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: max bianchi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Dec 2005 02:31:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance/m-p/1089845#M100369</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-27T02:31:22Z</dc:date>
    </item>
    <item>
      <title>Re: SQL performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance/m-p/1089846#M100370</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guixin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. TO the two SQLs , Do i need create index including vbeln and parvw for best performance, why?.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  Yes absolutely right.&lt;/P&gt;&lt;P&gt;  If the table does not have index on parvw,&lt;/P&gt;&lt;P&gt;  and this field is used in where conditions&lt;/P&gt;&lt;P&gt;  in other programs also, it is advisable&lt;/P&gt;&lt;P&gt;  to make index.&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;  Since VBELN is already index,&lt;/P&gt;&lt;P&gt;  we can make index only on parvw.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  WHY ?&lt;/P&gt;&lt;P&gt;  Because the database will take&lt;/P&gt;&lt;P&gt;  less time to find/search thru all records.&lt;/P&gt;&lt;P&gt;  Index is just like the 1page index&lt;/P&gt;&lt;P&gt;   in a book so that we can locate the CHAPTER&lt;/P&gt;&lt;P&gt;  very quickly, without having to scan&lt;/P&gt;&lt;P&gt;  thru each page manually.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2.Provided i have created a index including vbeln and parvw . What's difference between A and B ? why ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; gt_vbak&lt;/P&gt;&lt;P&gt; what is the purpose of this internalt table ???&lt;/P&gt;&lt;P&gt; yes, the main purpose is only for providing&lt;/P&gt;&lt;P&gt; a set of vbeln (for which data is required)&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;  PARVW comes in to picture AFTERWARDS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  Hence SECOND Sql is conceptually correct.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. More over second sql will be more faster&lt;/P&gt;&lt;P&gt;   because the conditions are more fixed.&lt;/P&gt;&lt;P&gt;  ie. both conditions (),()&lt;/P&gt;&lt;P&gt;   are not having AND in between,&lt;/P&gt;&lt;P&gt;  only one is having.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope it helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;amit m.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Dec 2005 04:44:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance/m-p/1089846#M100370</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-27T04:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: SQL performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance/m-p/1089847#M100371</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; Hi guixin,&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; 1. TO the two SQLs , Do i need create index including&lt;/P&gt;&lt;P&gt;&amp;gt; vbeln and parvw for best performance, why?.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt;   Yes absolutely right.&lt;/P&gt;&lt;P&gt;&amp;gt;   If the table does not have index on parvw,&lt;/P&gt;&lt;P&gt;&amp;gt;   and this field is used in where conditions&lt;/P&gt;&lt;P&gt;&amp;gt;   in other programs also, it is advisable&lt;/P&gt;&lt;P&gt;&amp;gt;   to make index.&lt;/P&gt;&lt;P&gt;&amp;gt;   &lt;/P&gt;&lt;P&gt;&amp;gt;   Since VBELN is already index,&lt;/P&gt;&lt;P&gt;&amp;gt;   we can make index only on parvw.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;ABSOLUTELY NOT&amp;lt;/b&amp;gt;. Creating an index only on parvw might in fact be counterproductive as a number of apps rely on the already created indexes. This might throw a loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt;   WHY ?&lt;/P&gt;&lt;P&gt;&amp;gt;   Because the database will take&lt;/P&gt;&lt;P&gt;&amp;gt;   less time to find/search thru all records.&lt;/P&gt;&lt;P&gt;&amp;gt;   Index is just like the 1page index&lt;/P&gt;&lt;P&gt;&amp;gt;    in a book so that we can locate the CHAPTER&lt;/P&gt;&lt;P&gt;&amp;gt;   very quickly, without having to scan&lt;/P&gt;&lt;P&gt;&amp;gt;   thru each page manually.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; 2.Provided i have created a index including vbeln and&lt;/P&gt;&lt;P&gt;&amp;gt; parvw . What's difference between A and B ? why ?&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt;  gt_vbak&lt;/P&gt;&lt;P&gt;&amp;gt;  what is the purpose of this internalt table ???&lt;/P&gt;&lt;P&gt;&amp;gt;  yes, the main purpose is only for providing&lt;/P&gt;&lt;P&gt;&amp;gt;  a set of vbeln (for which data is required)&lt;/P&gt;&lt;P&gt;&amp;gt;  &lt;/P&gt;&lt;P&gt;&amp;gt;   PARVW comes in to picture AFTERWARDS.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt;   Hence SECOND Sql is conceptually correct.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Depending on the DB and the SQL optimizer the second SQL might be the winner. (grabs the first key in the index and evaluates the second). &amp;lt;b&amp;gt;However you might as well see no or little difference: it really depends on the DB's SQL optimizer...&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; 3. More over second sql will be more faster&lt;/P&gt;&lt;P&gt;&amp;gt;    because the conditions are more fixed.&lt;/P&gt;&lt;P&gt;&amp;gt;   ie. both conditions (),()&lt;/P&gt;&lt;P&gt;&amp;gt;    are not having AND in between,&lt;/P&gt;&lt;P&gt;&amp;gt;   only one is having.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; I hope it helps.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; regards,&lt;/P&gt;&lt;P&gt;&amp;gt; amit m.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Dec 2005 05:48:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance/m-p/1089847#M100371</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-27T05:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: SQL performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance/m-p/1089848#M100372</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, F.J. Brandelik &lt;/P&gt;&lt;P&gt;          I think you are right. thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Dec 2005 07:53:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance/m-p/1089848#M100372</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-27T07:53:20Z</dc:date>
    </item>
    <item>
      <title>Re: SQL performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance/m-p/1089849#M100373</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi f.j. brandelik and guixin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. u are absolutely right.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. &amp;gt; Yes absolutely right.&lt;/P&gt;&lt;P&gt;&amp;gt; If the table does not have index on parvw,&lt;/P&gt;&lt;P&gt;&amp;gt; and this field is used in where conditions&lt;/P&gt;&lt;P&gt;&amp;gt; in other programs also, it is advisable&lt;/P&gt;&lt;P&gt;&amp;gt; to make index.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In fact, i had not seen the table vbpa&lt;/P&gt;&lt;P&gt;and not seen the index on 3 columns.&lt;/P&gt;&lt;P&gt;Thats the reason i had mentioned as above.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Moreover i also said that :&lt;/P&gt;&lt;P&gt;&amp;gt; If the table does not have index on parvw,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. If i had already seen the table, &lt;/P&gt;&lt;P&gt;   i definitely would not have mentioned it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for corrections and a very good in-depth&lt;/P&gt;&lt;P&gt;answer !&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;amit m.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Dec 2005 09:04:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance/m-p/1089849#M100373</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-27T09:04:33Z</dc:date>
    </item>
    <item>
      <title>Re: SQL performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance/m-p/1089850#M100374</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Amit Mittal&lt;/P&gt;&lt;P&gt;     Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Dec 2005 11:19:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-performance/m-p/1089850#M100374</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-27T11:19:26Z</dc:date>
    </item>
  </channel>
</rss>

