Please enable JavaScript to view this site.

R:BASE 11 Help

Navigation: Reference Index > Multi-User Guide > Increasing Application Performance

Surrounding the WHERE Clause with Parentheses

Scroll Prev Top Next More

You can easily gain processing speed by NOT surrounding your WHERE clauses with parentheses where non-text values are being used. When R:BASE sees parentheses, the values are evaluated as text, even though the values are not. By removing the parentheses, your code speeds will increase.

 

SET VAR t1 TIME = NULL

SET VAR t2 TIME = NULL

SET VAR vDiff INTEGER = NULL

SET VAR v1 TEXT = 'Seattle'

SET VAR v2 INTEGER = 93

SET VAR v3 INTEGER = 1000

 

--Example 4 - Slow

SET VAR t1 = (.#TIME)

SET VAR CheckNum INTEGER = 0

WHILE CheckNum < 40 THEN

SELECT AptCode INTO vAptCode INDICATOR ivAptCode +

FROM Airports WHERE (StCode = .v2 AND CityName +

CONTAINS .v1 AND Runway > .v3)

SET VAR CheckNum = (.CheckNum + 1)

ENDWHILE

SET VAR t2 = (.#TIME)

SET VAR vDiff = (.t2 - .t1)

SET VAR vTime = (RTIME(0,0,.vDiff))

PAUSE 2 USING .vTime

 

--Example 5 - Faster

SET VAR t1 = (.#TIME)

SET VAR CheckNum INTEGER = 0

WHILE CheckNum < 40 THEN

SELECT AptCode INTO vAptCode INDICATOR ivAptCode +

FROM Airports WHERE StCode = .v2 AND CityName +

CONTAINS .v1 AND Runway > .v3

SET VAR CheckNum = (.CheckNum + 1)

ENDWHILE

SET VAR t2 = (.#TIME)

SET VAR vDiff = (.t2 - .t1)

SET VAR vTime = (RTIME(0,0,.vDiff))

PAUSE 2 USING .vTime