|Getting Started||Documentation||Glish||Learn More||Programming||Contact Us|
|Version 1.9 Build 1556||
select from GER.MS where TIME in [select from ::POINTING where sumsqr(DIRECTION)>0 giving [TIME-INTERVAL/2=:=TIME+INTERVAL/2]]can generate many identical or overlapping intervals. They are sorted and combined where possible to make the set as small as possible.
The user can optimize a query by specifying the expression carefully. When using operator | | or &&, attention should be paid to the contents of the left and right branches. Both operators evaluate the right branch only if needed, so if possible the left branch should be the shortest one, i.e., the fastest to evaluate.
The user should also use functions, operators, and subqueries in a careful way.
^2 or POW(COL,2), because SQUARE is faster. It is also faster than COL*COL, because it accesses column COL only once.
^0.5 or POW(COL,0.5)
^2 is considerably faster than
SELECT FROM maintable WHERE time IN [SELECT time FROM othertable WHERE windspeed < 5]could also be expressed as
SELECT FROM maintable WHERE time IN [SELECT FROM othertable WHERE windspeed < 5 GIVING [time]]The latter (as a set) is slower. So, if possible, the column should be returned directly. This is also easier to write.
SELECT FROM maintable WHERE time IN [SELECT DISTINCT time FROM othertable WHERE windspeed < 5]Using the DISTINCT qualifier has the effect that duplicates are removed which often results in a much smaller set.
count([select column from table where expression]) >= N and exists (select from table where expression limit N)The second form is by far the best, because in that case the subquery will stop the matching process as soon as N matching rows are found. The first form will do the subquery for the entire table.
WHERE any(arraycolumn == value) and WHERE value IN arraycolumngive the same result. Operator IN is faster because it stops when it finds a match. If using ANY all elements are compared first and thereafter ANY tests the resulting bool array.