тыкнул "показать план запроса - всё", запрос:
Код:

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, причём идёт чтение из таблицы
