Author |
Message
|
knowledge_thirsty |
Posted: Thu Apr 17, 2008 4:21 am Post subject: Use of THE function |
|
|
Newbie
Joined: 07 Apr 2008 Posts: 2
|
Hi All,
I have a question . does the use of 'THE' function with select statement have any advantage in terms of performance in comparison to using only select statement?Or 'THE' is used only to select the first row from the List expression. I don't see anything in the documentaion regarding the performance issue.But wonder whether it improves the performance by stopping the selection whenever the first matching occurance found. Can anybody throw any light on this and provide me any useful link to know more about this particular function.
Thanks,
 |
|
Back to top |
|
 |
Gaya3 |
Posted: Thu Apr 17, 2008 5:21 am Post subject: |
|
|
 Jedi
Joined: 12 Sep 2006 Posts: 2493 Location: Boston, US
|
performance depends on your SELECT query rather than THE.
If you are using a simple/complex select statement, thats the required factor for performance checking
Regards
Gayathri _________________ Regards
Gayathri
-----------------------------------------------
Do Something Before you Die |
|
Back to top |
|
 |
knowledge_thirsty |
Posted: Thu Apr 17, 2008 5:47 am Post subject: |
|
|
Newbie
Joined: 07 Apr 2008 Posts: 2
|
Ok. I am using a simple select query like
SET employeeName.Result[] = select T.employee_name
FROM employee AS T
WHERE T.employee_id = '223344'
my question is, is there any difference in terms of performance in
the query above and the following query.
SET employeeName.Result[] = THE(select T.employee_name
FROM employee AS T
WHERE T.employee_id = '223344')
does the searching stop in the second case whenever the first match found? |
|
Back to top |
|
 |
AJStar |
Posted: Mon Apr 21, 2008 2:12 am Post subject: |
|
|
 Acolyte
Joined: 27 Jun 2007 Posts: 64
|
knowledge_thirsty wrote: |
SET employeeName.Result[] = select T.employee_name
FROM employee AS T
WHERE T.employee_id = '223344'
|
You are doing 2 things here (1) Query DB (2) Storing result
knowledge_thirsty wrote: |
SET employeeName.Result[] = THE(select T.employee_name
FROM employee AS T
WHERE T.employee_id = '223344') |
You are doing 3 things here (1) Query DB (2) using THE function (3) Storing result
knowledge_thirsty wrote: |
my question is, is there any difference in terms of performance in the query above and the following query. |
I would assume that it takes a fraction of second more for the second method.
knowledge_thirsty wrote: |
does the searching stop in the second case whenever the first match found? |
The "THE" function returns a non-list result, taking a list as argument (though not mandatorily a list). Your SELECT query is independent. _________________ Regards
AJ |
|
Back to top |
|
 |
mgk |
Posted: Mon Apr 21, 2008 3:40 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
It is correct that the "THE" function is performed independently of the "SELECT". In the case you give (using a WHERE clause) I believe that AJStar is correct. Where "THE" can be faster is if your SELECT returns a long list with many rows (e.g. if you did not use a WHERE clause) and the cost of performing the "THE" will be outweighed by the cost of the assignment of the whole result set to a tree where you did not want the extra data.
regards, _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
Back to top |
|
 |
|