2

For example:

select * from A where 
predicate1 and 
predicate2 and 
predicate3;

If predicate1 return false, will the program continue to evaluate other predicates or not? Cheers.

New Bentley
  • 465
  • 5
  • 9

1 Answers1

3

The optimizer might reorder predicates, and in the general case, all predicates will be executed:

sqlite> .explain on
sqlite> explain select 1 where 11=22 and 33=44;
addr  opcode         p1    p2    p3    p4             p5  comment      
----  -------------  ----  ----  ----  -------------  --  -------------
0     Trace          0     0     0                    00               
1     Integer        11    3     0                    00               
2     Integer        22    4     0                    00               
3     Eq             4     2     3                    72               
4     Integer        33    3     0                    00               
5     Integer        44    5     0                    00               
6     Eq             5     4     3                    72               
7     And            4     2     1                    00               
8     IfNot          1     12    1                    00               
9     Goto           0     13    0                    00               
10    Integer        1     6     0                    00               
11    ResultRow      6     1     0                    00               
12    Halt           0     0     0                    00               
13    Goto           0     10    0                    00               
CL.
  • 173,858
  • 17
  • 217
  • 259