× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



The host variable has a value that is constant for the scope of the statement. Thus there would be no reason to calculate the expression more than once. The expression (2011 concat :RPTTXYR) can be evaluated [as cast to the data type\attributes of the column being compared; implicit vs explicit CAST should be moot] and implemented as the effective literal it is, before the rest of the query evaluation\optimization begins. That expression, the effective constant, just as a literal would is constant, is a good potential candidate for implementation on an index defined on column ARTXYR when coded in the WHERE clause as:
and A.artxyr = 2011 concat :RPTTXYR

While it is entirely possible the optimizer does not have the capability to do so [I believe it does], the query implementation _should_ be capable of effecting the equivalent of the following for its optimization _because_ the given expression is as good as a literal:
and A.artxyr = :Evaluated_Expression_2011_concat_hvRPTTXYR

I would expect VE to confirm that potential.

Regards, Chuck

On 30 May 2012 09:50, Vern Hamberg wrote:
Tom - I'll jump in here - the calculation has to be done for every
record you are testing - this prevents the use of any index on
A.artxyr.

This is generally true, and may depend on where the calculation is.

Also, I'm inclined to think implicit casts may have some bearing on
performance. Not sure, would have to run through Visual Explain to
see.

In this case, it'd be easy enough to run 2 SELECTs in Navigator, one
with this concatenation of 2011 and a constant that is a valid value
for RPTTXYR. The other would use directly the value that resulted
from the concatenation.

On 5/30/2012 10:06 AM, Tom E Stieger wrote:

On a side note, why does this matter for performance?

Birgitta Hauser on Tuesday, May 29, 2012 10:38 PM wrote:
Scott Klement on Tuesday, 29.5 2012 23:58 wrote:
This line looks suspicious to me:
and A.artxyr = 2011 || :RPTTXYR

To me too!
For performance issues you should avoid concatenating those
things in the SQL statement, calculate the variable value in your
RPG and use it as follows:

MyVar = '2011' + RPTTXYR;

Select ...
Where a.ARTXYR = :MyVar




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.