[Progress Communities] [Progress OpenEdge ABL] Forum Post: RE: Clarification on logical in query

Status
Not open for further replies.
F

frank.meulblok

Guest
In the scenario given, I'd worry more about the functional difference between "table.active = table.active" (always true for all records) vs. "table.active = YES" (not always true) / "table.active = NOT table.active" (never true for any record) vs. "table.active = NO" (not always true). Comparing a field to itself doesn't often make a lot of sense. Also, comparisons on variables or table fields *do* get locked in when the WHERE clause is evaluated, and *are* picked up when indexes are selected. COMPILE XREF this: DEFINE TEMP-TABLE stuff NO-UNDO FIELD thing AS CHARACTER FIELD active AS LOGICAL INDEX thing IS UNIQUE thing INDEX active active. DEFINE TEMP-TABLE morestuff NO-UNDO FIELD active AS LOGICAL. DEFINE VARIABLE icount AS INT NO-UNDO. DEFINE VARIABLE lfindme AS LOGICAL NO-UNDO. PAUSE 0 BEFORE-HIDE. DO icount = 1 TO 100000: CREATE stuff. ASSIGN thing = GUID active = (RANDOM (20,200) MOD 2 = 0). END. CREATE morestuff. ETIME(TRUE). FOR EACH stuff WHERE stuff.active = lfindme: END. MESSAGE ETIME. ETIME(TRUE). FOR EACH stuff WHERE stuff.active = FALSE: END. MESSAGE ETIME. ETIME(TRUE). FOR EACH stuff WHERE stuff.active = morestuff.active: END. MESSAGE ETIME. and see that all 3 FOR EACH'es use the same index. User-defined functions and class methods are a different matter.

Continue reading...
 
Status
Not open for further replies.
Top