When to avoid dynamic expressions in stream queries
Where possible, use static expressions in preference to dynamic expressions. This allows the compiler to optimize the query to improve performance. For example, consider the following query:
stream<float> vwaps := from t in all ticks
within vwapPeriod
select wavg(t.price,t.volume);
When vwapPeriod is a monitor global variable whose value does not change, then it is preferable to copy the value to a local variable first. For example:
float period := vwapPeriod;
stream<float> vwaps := from t in all ticks
within period
select wavg(t.price,t.volume);
Similarly, if it is known that a given action call always returns the same value, then it is preferable to copy the result to a local variable and use this in place of the action call. For example:
float period := getVwapPeriod(symbol);
stream<float> vwaps := from t in all ticks
within period
select wavg(t.price,t.volume);
Copyright © 2013
Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or Terracotta Inc., San Francisco, CA, USA, and/or Software AG (Canada) Inc., Cambridge, Ontario, Canada, and/or, Software AG (UK) Ltd., Derby, United Kingdom, and/or Software A.G. (Israel) Ltd., Or-Yehuda, Israel and/or their licensors.