‎2008 Mar 14 4:58 AM
Hello everybody i know that where clause is efficient than check condition.
But i want to know if in the following example,
even after finding SBOOK_WA-CARRID = 'LH' ,
DOES THE CHECK CONDITION TERMINATES?? OR KEEP SEARCING TILL THE END OF INTERNAL TABLE?
IN THE 2nd EXAMPLE,
DOES THE WHERE CLAUSE EXHIBIT THE SAME PHENOMENON?
1st example:
SELECT * FROM SBOOK INTO SBOOK_WA.
CHECK: SBOOK_WA-CARRID = 'LH' AND
SBOOK_WA-CONNID = '0400'.
ENDSELECT.
-
2nd example:
SELECT * FROM SBOOK INTO SBOOK_WA
WHERE CARRID = 'LH' AND
CONNID = '0400'.
ENDSELECT.
‎2008 Mar 14 5:07 AM
Hi,
If you code select statement with where condition then it
is very efficient.Because the where condition will execute first and then the select
statement will get data from data base with selected fields,
if you code the select statement after that if you put check statement,
first select statement will execute with out key base.Means the performance decreases.
(see searching known thing is easy than unknowing thing.).
so its better to go for select statement with where condition.
regards
swami.
‎2008 Mar 14 5:01 AM
Hi
the check statement will work as desired, but performance wise the second select query with th where clause is better
regards
parminder
‎2008 Mar 14 5:04 AM
Hi,
Check statement will give low performance compare to where.
B'cause After selecting the record for database table you are checking the value.
WHERE: At the time of selection records from table you are checking. So based on condition record will select otherwise it will go for nect record with that database connection only.
In first example. : It will terminate the selection.No next search...
Second : it will continue the search....
‎2008 Mar 14 5:07 AM
Hi,
If you code select statement with where condition then it
is very efficient.Because the where condition will execute first and then the select
statement will get data from data base with selected fields,
if you code the select statement after that if you put check statement,
first select statement will execute with out key base.Means the performance decreases.
(see searching known thing is easy than unknowing thing.).
so its better to go for select statement with where condition.
regards
swami.
‎2008 Mar 14 5:16 AM
Ok ,,Now i want to know if the condition SBOOK_WA-CARRID
= 'LH' is repeated for the 2nd time in the database table.Then will the Check & Where condition continue to search for it even after having encountered the above mentioned condition already??
‎2008 Mar 14 5:17 AM
Hi,
If where clause is used in select query, it filters the database records according to the condn. and retrieves values into the internal table.
When, check statement is used, it checks for the condition only after the selection. This will increase the execution time.
In addition, the statements after check statemnt (in the same event) will be executed only if the condition mentioned in check statement is true.
Reward if helpful.
Regards,
Ramya
‎2008 Mar 14 5:23 AM
Hi,
First Example will not work.
Second Example will work.
Regards,
Dhruv Shah
‎2008 Mar 14 5:27 AM
My question is ,
IF SBOOK_WA-CARRID = 'LH' CONDITION IS AGAIN PRESENT IN THE DATABASE TABLE ,,,,WILL THE CHECK CONDITION SEARCH IT AGAIN EVEN AFTER FINDING IT FOR THE FIRST TIME IN THE TABLE???OR SIMPLY TERMINATE IN THE FIRST TIME THE CONDITION SATISFIES??
SIMILARLY DOES THE WHERE CLAUSE CONTINUE SEARCHING EVEN AFTER HAVING FOUND THE CONDITION FOR THE FIRST TIME??
PLEASE HELP ME IN THIS ASPECT.
‎2008 Mar 14 6:26 AM
hi saswat,
If it's an internal table, why do you want to select it instead of looping/reading it?
and incase u're looping it, you need not worry for the number of fetches, because it brings you all the relevant records having given the condition.
even otherwise, if it's a select to a database table, one select statement will fetch you all the relevant records for the given where/check condition. So both the clauses will bring in ALL the records in ONE go be it a select to a db table / looping an ITAB.
Thanks,
VV