T-SQL 1=1 Performance Hit

前端 未结 8 762
谎友^
谎友^ 2020-12-06 04:33

For my SQL queries, I usually do the following for SELECT statements:

SELECT ...
FROM table t
WHERE 1=1
  AND t.[column1] = @param1
  AND t.[column2] = @para         


        
8条回答
  •  臣服心动
    2020-12-06 05:14

    It is likely that if you use the profiler and look, you will end up seeing that the optimizer will end up ignoring that more often than not, so in the grand scheme of things, there probably won't be much in the way of performance gain or losses.

提交回复
热议问题