‎2007 Aug 20 12:33 PM
Can we use Select single inside the loop..? will it cause any performance issue....?
Regards,
Murugan Arumugam
‎2007 Aug 20 12:34 PM
try to avoid select statement inside loop it will decrease the performance
‎2007 Aug 20 12:34 PM
try to avoid select statement inside loop it will decrease the performance
‎2007 Aug 20 12:35 PM
HI,
yaa u can.
but u can select only one row using this.
this is good compared to select * in performance wise.
rgds,
bharat.
‎2007 Aug 20 12:35 PM
You Can.
Are you using it for validation or reading data. If so then you may wish to use the
AT NEW command
So that you only do the read each time the where condition would change.
‎2007 Aug 20 12:35 PM
Hi,
Why u use select single in loop statement better write your query befor loop statement and then use read statement for use this data according to key field.
Rewards points if it is useful.
‎2007 Aug 20 12:43 PM
Hi,
there is no issues using like that.In select single u only have to take care whether the conditions used to fetch includes all primary key fields.
‎2007 Aug 20 12:44 PM
Hello,
<b>Select statement inside a loop</b> is not a good programming practice. It will make some <b>performance issues</b>. Instead of this u can select the record in to one<b> internal table</b> fist and u can use the <b>read table</b> command inside the loop statement. That is better.
Reward if helpful,
Regards,
LIJO JOHN
‎2007 Aug 20 12:47 PM
Hi Murugan,
As far as performance is concerned Select single is not advisable. Better would be, you retreive the data outside the loop into a internal table and then use READ statement. But if the amount of data is less then you can go for SELECT SINGLE also. It will serve your purpose.
It is a subjective matter and depends on the amount of data you are handling.
Rewards points if helpful
regards
Sourabh Verma
‎2007 Aug 20 12:48 PM
Hi,
Avoid select statement using inside loop
it will decrease the performance.
‎2007 Aug 20 12:48 PM
Hi murugan,
The <i><b>Best answer</b></i> i could get 4 u is this....
if you are 100% sure , you can't code a database join, then :
Theoretically , the "for all entries" clause has an advantage over a loop of select singel by primary key. This is becuase the abap interpreter can group together several rows in the itab into one select (see note <b>48230</b>) so it could get the requested result using less conversations with the database.
The down side is that by doing so, the where predicates will not be a simple equation predicates, they may become "in" predicates and so on (see note <b>48230</b>). This change in the sql may lead to a more costly access path.
So, unfortunatly, you will probably be forced to write and test both options and see which costs less.
by costs i mean total getpages or "in db2 time" for the whole workload, and not transaction elapsed time.)
as a rule of thumb I would lean to select single by primary key, over "for all entries" ... but as i said, its depends on several factors....
Above article is taken from...
<i><b>http://blogs.ittoolbox.com/sap/db2/archives/for-all-entries-vs-db2-join-8912</b></i>
Refer that too...
Hope it helps!!!
<i><b>*Reward useful answers*</b></i>
Regards,
<b>Naveenan</b>
‎2007 Sep 28 8:30 AM