тыкнул "показать план запроса - всё", запрос:
Код:
![Выделить весь код](images/misc/selectcode.png)
declare @val1 integer;
select top 20 id from table1 where (@val is null) or code<>'123'
показал, что (@val is null) or code<>'123' выполняется дольше, чем select top 20 id, причём идёт чтение из таблицы
![Sad](images/smilies/sad.gif)