03-11-2008 4:20 AM
Plz tell me the difference between select single and select upto one row.
03-11-2008 4:25 AM
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.
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.
The best way to find out is through sql trace or runtime analysis.
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.
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.
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.
Mainly: to read data from
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.
Reward points..
03-11-2008 4:22 AM
Hi,
select single * does not need an END SELECT whereas for select up to 1 rows need END SELECT.
performance wise it is better to use select ...up to 1 rows.
rgds,
bharat.
03-11-2008 4:22 AM
Hi
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.
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.
Mainly: to read data from
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.
Mainly: to check if entries exist.
03-11-2008 4:25 AM
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.
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.
The best way to find out is through sql trace or runtime analysis.
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.
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.
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.
Mainly: to read data from
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.
Reward points..
03-11-2008 4:25 AM
Hi Pavan,
Please check the below links for your query :
http://www.sap-img.com/abap/difference-between-select-single-and-select-upto-one-rows.htm
Regards,
Esha Raj
Edited by: Esha Raj on Mar 11, 2008 5:28 AM
03-11-2008 4:27 AM
select single requires all key fields in the where condition. It checks all the records based on the condition and picks the required record whereas select upto one row picks the first record. based on performance issue, select upto one row is best to use.
03-11-2008 4:28 AM
Hi,
Select Single and the Select up to 1 rows is used to extract the single row from the database.
The exact diff is:
If we know In mara table has a primary key field has a matnr, that for each material number only one record exists,
duplicates not allowed.
If use Select Single Command to get that one record . It will not again go tot check for if there is another record available for same matnr.
we use select up to 1 rows it will extarct the 1 row from the
dbtable and again it will go and check if there is another record availble or not for same material no.
It will take one extra rotattion.
Keep in mind if use select single u make to populate all the key fields. Otherwise it will extract the first row from the database.
data: it_mara like mara occurs 1 with header line.
Select single * from mara into it_mara where matnr = '000000000100000174'.
append it_mara.
select * from mara into it_mara
up to 1 rows
where matnr = '000000000100000174'.
append it_mara.
endselect.
Loop at it_mara.
endloop.
U can execute above code put break point feel the diff.
If it helpful rewards points.
Cheers,
vasavi.
03-11-2008 4:28 AM
Hai Pavan,
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.
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.
The best way to find out is through sql trace or runtime analysis.
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.
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.
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.
Mainly: to read data from
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.
Mainly: to check if entries exist.
Regards.
Eshwar.
03-11-2023 6:57 AM