Problem solve Get help with specific problems with your technologies, process and projects.

# What difference does a 1 = 1 predicate make?

What difference does a 1 = 1 predicate make? For example, consider the following SQL queries:
```SELECT LASTNAME, FIRSTNAME, ADDR1 FROM EMP

SELECT LASTNAME, FIRSTNAME, ADDR1 FROM EMP WHERE 1 = 1
```
Is there any difference in the treatment of the optimizer for the above two queries?
There should be no discernible difference between the two SQL statements you specify. In fact, I would guess that the second one would be ever so slightly less efficient than the first one because of the additional predicate that is involved.

I've never seen an approach like this before. Perhaps you are confusing this with the approach of appending OR...

0 = 1 to a predicate to force DB2's hand when selecting an index at bind time. For example, consider this statement:

```SELECT a,b,c
FROM    table1
WHERE d between 'A' and 'F'
AND      e > 1500;
```
```SELECT a,b,c
FROM    table1
WHERE d between 'A' and 'F'
AND      (e > 1500 OR 0 = 1);
```
If there were two indexes, one on column d and one on column e, you could add OR 0 = 1 to one of the predicates to get DB2 to choose the index for the other. For example: This would eliminate the index on e, and DB2 would choose the index on d. But this will not help in your situation because there are no other predicates.

Close