Answered
Using 1 = 1 in SQL Statements
I have just been told by our DBA that we have to go through
our code and remove the "WHERE 1 = 1" in our SQL statements on a
SQL 2000 database. He said it is a performance issue when nothing
else follows it (no AND's).
For example (the wrong way):
SELECT this_ID FROM thistable WHERE 1 = 1
Versus...
SELECT this_ID FROM thistable WHERE 1 = 1 AND this_ID = 1001
He said Microsoft said that this is causing a performance hit when there is no AND clauses after the WHERE.
Some of these SQL statements are pretty big and there is no practical way to do a CFIF beforehand.
Has anyone heard of a performance hit like this? If so, how much of a hit? The main table in the DB has about 2 million records with full text indexes.
Thanks,
Rob in Tampa
For example (the wrong way):
SELECT this_ID FROM thistable WHERE 1 = 1
Versus...
SELECT this_ID FROM thistable WHERE 1 = 1 AND this_ID = 1001
He said Microsoft said that this is causing a performance hit when there is no AND clauses after the WHERE.
Some of these SQL statements are pretty big and there is no practical way to do a CFIF beforehand.
Has anyone heard of a performance hit like this? If so, how much of a hit? The main table in the DB has about 2 million records with full text indexes.
Thanks,
Rob in Tampa
