‎2007 Dec 18 10:22 PM
Hi,
I have a database table with 7 key fields. I need to fetch a single row using 4 of the keys.
Which is the best way out of below two and why?
1. select single * from table where key 1 key 2 key 3 key 4 are known.
2. select * from table where key 1 key 2 key 3 key 4 are known.
exit.
end select.
3. Select upto 1 row.
Please advise.
Thanks!
‎2007 Dec 18 10:27 PM
Performance point of view - Select single is best than others ( Here you get extened sysntx error since you do not have key fields in where clause ,other way use select upto 1 rows.
Thanks
Seshu
‎2007 Dec 18 10:27 PM
Performance point of view - Select single is best than others ( Here you get extened sysntx error since you do not have key fields in where clause ,other way use select upto 1 rows.
Thanks
Seshu
‎2007 Dec 19 12:17 AM
Hi Shreyas,
When you use SELECT * ... END SELECT statement to access your table, the system will access the database for value each time you loop. This will cause the traffic to increase and memory usage. Though you may be using it to select one row but its always good practice to avoid using this searching method unless situation needs you to do so.
However, if you use SELECT SINGLE and using KEYS, this will limit the search and keep the memory usage low plus reducing the execution time.
Definitely SELECT SINGLE will improve your program performance.
You can use performance tool like SE30 or ST05 to check out your SINGLE SEARCH...
I hope my explanation is correct.
Thanks
William Wilstroth
‎2007 Dec 19 1:43 AM
Hi, some days ago, I have the same problem, and I found an article in the WIKI : [ Difference between select single and select upto.|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/difference%2bbetween%2bselect%2bsingle%2band%2bselect%2bupto.]. Hope this can help you.
In that article, the author compares the difference between SELECT SINGLE and SELECT UP TO, and I think 'SELECT SINGLE' and 'SELECT * .EXIT. ENDSELECT. ' have the same effect.
Regards,
feng.
‎2007 Dec 19 2:20 AM
Hi Shreyas,
SELECT SINGLE is the best way to go here(in view of performance!!!)
Please try to include the other key fields(complete key) in the WHERE clause
to fetch the unique entry exactly!!!!
Cheers,
Abdul Hakim
Mark all useful answers!!!
‎2007 Dec 19 2:52 AM
TOPIC :- Use select up to 1 rows instead of select single.
TIP :-
Its very usefull to use select upto 1 rows instead select single statement,
For example you can check it out with this code.
REPORT z_test1.
data: ls1 type sflight-fldate,
ls2 type sflight-fldate,
a type i,
b type i,
c type i.
get run time field a.
select single fldate
from sflight
into ls1
where carrid = 'LH' and connid eq '400'.
get run time field b.
c = b - a.
write:/ 'runtime for select single:',c.
write:/ ls1.
get run time field a.
select fldate
from sflight
into ls2
up to 1 rows
where carrid = 'LH' and connid eq '400'.
endselect.
get run time field b.
c = b - a.
write:/ 'runtime for upto 1 rows:',c.
write:/ ls2.
Rewards if useful.........
Minal
‎2007 Dec 19 3:41 AM
hai,,
please use select single............
it will give a better performance......
jai.m