<?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: Optimising SELECT from a database in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimising-select-from-a-database/m-p/1847954#M359504</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;u need to write a select statement with key fields and other fields....before that try to create an index for the table based on the fields used in where list....so database access will be fast....&lt;/P&gt;&lt;P&gt;now, looping the internal table check and move data to another internal table using binary search and with key fields....before this u need to do a sort on the table for binary search to be useful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        Ramesh Babu Chirumamilla&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 29 Jan 2007 14:41:07 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-01-29T14:41:07Z</dc:date>
    <item>
      <title>Optimising SELECT from a database</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimising-select-from-a-database/m-p/1847953#M359503</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to retrieve records from a huge transaction table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. I want to retrieve records into an internal table&lt;/P&gt;&lt;P&gt;2. If there was a duplicate record that is about to move into the same internal table it will be moved into another internal table.&lt;/P&gt;&lt;P&gt;3. Someone told me that using a LOOP may not be that effective. Using internal table KEYS and BINARY SEARCH would be ideal.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have come here to seek for urgent guidance and knowledge.&lt;/P&gt;&lt;P&gt;Hope you all can help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Jan 2007 14:38:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimising-select-from-a-database/m-p/1847953#M359503</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-29T14:38:09Z</dc:date>
    </item>
    <item>
      <title>Re: Optimising SELECT from a database</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimising-select-from-a-database/m-p/1847954#M359504</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;u need to write a select statement with key fields and other fields....before that try to create an index for the table based on the fields used in where list....so database access will be fast....&lt;/P&gt;&lt;P&gt;now, looping the internal table check and move data to another internal table using binary search and with key fields....before this u need to do a sort on the table for binary search to be useful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        Ramesh Babu Chirumamilla&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Jan 2007 14:41:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimising-select-from-a-database/m-p/1847954#M359504</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-29T14:41:07Z</dc:date>
    </item>
    <item>
      <title>Re: Optimising SELECT from a database</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimising-select-from-a-database/m-p/1847955#M359505</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;First of all, try to use an existing table index on the SELECT statement. I think you will have to use a loop to go through each row of the table to see if there are duplicates.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It would be best if you could post the code you have or at least more detailed requirements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Jan 2007 15:05:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimising-select-from-a-database/m-p/1847955#M359505</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-29T15:05:42Z</dc:date>
    </item>
    <item>
      <title>Re: Optimising SELECT from a database</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimising-select-from-a-database/m-p/1847956#M359506</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;Suppose you are trying to get records from a table TAB, and A, B and C are the records which need to be fetched.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select A B C &lt;/P&gt;&lt;P&gt;from TAB&lt;/P&gt;&lt;P&gt;into wa&lt;/P&gt;&lt;P&gt;where &amp;lt;cond&amp;gt;&lt;/P&gt;&lt;P&gt;order by A B C.&lt;/P&gt;&lt;P&gt;if sy-subrc eq 0.&lt;/P&gt;&lt;P&gt;  if sy-index eq 1.&lt;/P&gt;&lt;P&gt;   append wa to itab1.&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;  if wa-A eq wa1-A and wa-B eq wa1-B and wa-C eq wa1-C.&lt;/P&gt;&lt;P&gt;   append wa to itab2.&lt;/P&gt;&lt;P&gt;  else.&lt;/P&gt;&lt;P&gt;   append wa to itab1.&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt; move wa to wa1.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;endselect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At the end of this select, all the unique records will be in itab1 and all the duplicate records will be in itab2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward ponits if found useful..!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Abhishek&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Jan 2007 03:53:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimising-select-from-a-database/m-p/1847956#M359506</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-30T03:53:09Z</dc:date>
    </item>
    <item>
      <title>Re: Optimising SELECT from a database</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimising-select-from-a-database/m-p/1847957#M359507</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;Get only required fields from the table based on thier position in table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;put maximum comparision fields in where conditions. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort the table and move the duplicate entry into another table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Shiva&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Jan 2007 05:23:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimising-select-from-a-database/m-p/1847957#M359507</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-30T05:23:19Z</dc:date>
    </item>
    <item>
      <title>Re: Optimising SELECT from a database</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimising-select-from-a-database/m-p/1847958#M359508</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Andrew,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do u want to select the records from the databese... then move the duplicate record in to another internal table.. is this u requirement!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;first select the data into let us say Ex IT_TAB1.&lt;/P&gt;&lt;P&gt;suppose F1 and F2 Are key fields in u r table.&lt;/P&gt;&lt;P&gt;then &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SORT IT_TAB1 BY F1 F2.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;..&lt;/P&gt;&lt;P&gt;THEN&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;IT_TAB2[] = IT_TAB1[].
SORT IT_TAB2 BY F1 F2.
DELETE ADJACENT DUPLICATE FROM IT_TAB2 COMPLARING F1 F2..&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now u have two tables IT_TAB1 contains all the Records&lt;/P&gt;&lt;P&gt;IT_TAB2 contains only the single records..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Jan 2007 12:29:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimising-select-from-a-database/m-p/1847958#M359508</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-30T12:29:50Z</dc:date>
    </item>
    <item>
      <title>Re: Optimising SELECT from a database</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimising-select-from-a-database/m-p/1847959#M359509</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;ur 2nd requirement is not very clear.&lt;/P&gt;&lt;P&gt;u want to have unique entries in one table and the duplicate entries in another table ?&lt;/P&gt;&lt;P&gt; if so...u can try the following logic:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for unique entries:&lt;/P&gt;&lt;P&gt;itab1[] = itab[].&lt;/P&gt;&lt;P&gt;sort itab1 by f1.&lt;/P&gt;&lt;P&gt;delete adjacent duplicates from itab1 comparing f1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for duplicate entries:&lt;/P&gt;&lt;P&gt;sort itab by f1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt;if itab-f1 = itab2-f1.&lt;/P&gt;&lt;P&gt;  move itab-f1 to itab3-f1.&lt;/P&gt;&lt;P&gt;  append itab3.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;itab2 = itab.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt; this itab3 will have all duplicate entries.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;madhu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Jan 2007 14:33:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimising-select-from-a-database/m-p/1847959#M359509</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-30T14:33:01Z</dc:date>
    </item>
  </channel>
</rss>

