<?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: Select single in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-single/m-p/2439673#M545972</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;According to SAP Performance course the SELECT UP TO 1 ROWS is faster than SELECT SINGLE because you are not using all the primary key fields. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select single is a construct designed to read database records with primary key. In the absence of the primary key, it might end up doing a sequential search, whereas the select up to 1 rows may assume that there is no primary key supplied and will try to find most suitable index. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The best way to find out is through sql trace or runtime analysis. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use "select up to 1 rows" only if you are sure that all the records returned will have the same value for the field(s) you are interested in. If not, you will be reading only the first record which matches the criteria, but may be the second or the third record has the value you are looking for. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The System test result showed that the variant Single * takes less time than Up to 1 rows as there is an additional level for COUNT STOP KEY for SELECT ENDSELECT UP TO 1 ROWS. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The 'SELECT SINGLE' statement selects the first row in the database that it finds that fulfils the 'WHERE' clause If this results in multiple records then only the first one will be returned and therefore may not be unique. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mainly: to read data from &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The 'SELECT .... UP TO 1 ROWS' statement is subtly different. The database selects all of the relevant records that are defined by the WHERE clause, applies any aggregate, ordering or grouping functions to them and then returns the first record of the result set. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mainly: to check if entries exist.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select Single &lt;/P&gt;&lt;P&gt;You need to mention all the key fields of the table. &lt;/P&gt;&lt;P&gt;No END SELECT required.&lt;/P&gt;&lt;P&gt;More performance compared to upto 1 row.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Where as UP to 1 row.&lt;/P&gt;&lt;P&gt;YOu can use if you do not have all the primiary key fields available. &lt;/P&gt;&lt;P&gt;END SELECT requeired.&lt;/P&gt;&lt;P&gt;Since all keys are not passing, possiblities of have other rows which satisfies the condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select Statement with EndSelect is a loop, which in a single run retrieves a single Record. This Record has to be stored in a Work Area and then appended into an Internal Table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select Statements without EndSelect is not a loop and it retrieves the whole Record set matching the Criteria in a single shot and has to be Stored in an Internal Table Directly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The most important thing to remember about the SELECT SINGLE is&lt;/P&gt;&lt;P&gt;There are several things to remember:&lt;/P&gt;&lt;P&gt;1) It retrieves only one row&lt;/P&gt;&lt;P&gt;2) It does not need an ENDSELECT statement&lt;/P&gt;&lt;P&gt;3) THE FULL KEY OF THE TABLE MUST BE INCLUDED IN &lt;/P&gt;&lt;P&gt;THE WHERE CLAUSE OF THE SELECT STATEMENT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to say in simple&lt;/P&gt;&lt;P&gt;SELECT SINGLE: &lt;/P&gt;&lt;P&gt;1. Select single is based on PRIMARY KEY&lt;/P&gt;&lt;P&gt;2. It will take the first record directly without searching of all relevant records.(Though you have lot of records for given condition)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT UPTO 1 ROW : &lt;/P&gt;&lt;P&gt;It will check all records for given condition and take the first record .&lt;/P&gt;&lt;P&gt;It means in select single no searching, where as other searching.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Therefore, select single more efficient than UPTO 1 ROW.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Seshu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 24 Jun 2007 00:22:19 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-06-24T00:22:19Z</dc:date>
    <item>
      <title>Select single</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-single/m-p/2439671#M545970</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am new to ABAP , When we go for select single and when we go for select upto  1 row.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Babu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 Jun 2007 23:40:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-single/m-p/2439671#M545970</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-23T23:40:34Z</dc:date>
    </item>
    <item>
      <title>Re: Select single</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-single/m-p/2439672#M545971</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;select single will pick a unique record &amp;amp; select up to 1 rows will pick ANY one record that satisifes the WHERE condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;~Suresh&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;P.S. Pl search the forum &amp;amp; you will see a number of threads where thsi issue was discussed&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 24 Jun 2007 00:19:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-single/m-p/2439672#M545971</guid>
      <dc:creator>suresh_datti</dc:creator>
      <dc:date>2007-06-24T00:19:43Z</dc:date>
    </item>
    <item>
      <title>Re: Select single</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-single/m-p/2439673#M545972</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;According to SAP Performance course the SELECT UP TO 1 ROWS is faster than SELECT SINGLE because you are not using all the primary key fields. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select single is a construct designed to read database records with primary key. In the absence of the primary key, it might end up doing a sequential search, whereas the select up to 1 rows may assume that there is no primary key supplied and will try to find most suitable index. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The best way to find out is through sql trace or runtime analysis. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use "select up to 1 rows" only if you are sure that all the records returned will have the same value for the field(s) you are interested in. If not, you will be reading only the first record which matches the criteria, but may be the second or the third record has the value you are looking for. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The System test result showed that the variant Single * takes less time than Up to 1 rows as there is an additional level for COUNT STOP KEY for SELECT ENDSELECT UP TO 1 ROWS. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The 'SELECT SINGLE' statement selects the first row in the database that it finds that fulfils the 'WHERE' clause If this results in multiple records then only the first one will be returned and therefore may not be unique. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mainly: to read data from &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The 'SELECT .... UP TO 1 ROWS' statement is subtly different. The database selects all of the relevant records that are defined by the WHERE clause, applies any aggregate, ordering or grouping functions to them and then returns the first record of the result set. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mainly: to check if entries exist.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select Single &lt;/P&gt;&lt;P&gt;You need to mention all the key fields of the table. &lt;/P&gt;&lt;P&gt;No END SELECT required.&lt;/P&gt;&lt;P&gt;More performance compared to upto 1 row.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Where as UP to 1 row.&lt;/P&gt;&lt;P&gt;YOu can use if you do not have all the primiary key fields available. &lt;/P&gt;&lt;P&gt;END SELECT requeired.&lt;/P&gt;&lt;P&gt;Since all keys are not passing, possiblities of have other rows which satisfies the condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select Statement with EndSelect is a loop, which in a single run retrieves a single Record. This Record has to be stored in a Work Area and then appended into an Internal Table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select Statements without EndSelect is not a loop and it retrieves the whole Record set matching the Criteria in a single shot and has to be Stored in an Internal Table Directly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The most important thing to remember about the SELECT SINGLE is&lt;/P&gt;&lt;P&gt;There are several things to remember:&lt;/P&gt;&lt;P&gt;1) It retrieves only one row&lt;/P&gt;&lt;P&gt;2) It does not need an ENDSELECT statement&lt;/P&gt;&lt;P&gt;3) THE FULL KEY OF THE TABLE MUST BE INCLUDED IN &lt;/P&gt;&lt;P&gt;THE WHERE CLAUSE OF THE SELECT STATEMENT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to say in simple&lt;/P&gt;&lt;P&gt;SELECT SINGLE: &lt;/P&gt;&lt;P&gt;1. Select single is based on PRIMARY KEY&lt;/P&gt;&lt;P&gt;2. It will take the first record directly without searching of all relevant records.(Though you have lot of records for given condition)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT UPTO 1 ROW : &lt;/P&gt;&lt;P&gt;It will check all records for given condition and take the first record .&lt;/P&gt;&lt;P&gt;It means in select single no searching, where as other searching.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Therefore, select single more efficient than UPTO 1 ROW.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Seshu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 24 Jun 2007 00:22:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-single/m-p/2439673#M545972</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-24T00:22:19Z</dc:date>
    </item>
  </channel>
</rss>

