useless WHERE conditions

gms_xy at gmx.de gms_xy at gmx.de
Fri Oct 17 11:00:50 CEST 2014


To have a human-readable SQL code, I am used in following code formatting:

SELECT
    a
FROM
    tbl
WHERE
    1=1   --<<-- absolutely useless, but nice for formatting
    AND col1 = 1
    AND col2 = 2
    AND col3 = 3

Instead of "1=1", some other databases accept "TRUE". When I have multiple OR-conditions, I start with "1=0" or "FALSE". Writing statements this way I noticed long execution times in MonetDB. Omitting the logical where-condition "1=1" results in very fast execution time. So I guess, MonetDB is really checking on every row, if 1=1.



More information about the developers-list mailing list