sql server - Additional "where column is not null" significantly slows down a query execution time -


in sql server have query:

select      a, b, year(c), max(convert(date,c)), d      some_view     not null     , b = 'str1'     , (x in ('str2','str3', ...) or = 'str4')     --and c not null     --and d not null group     a, b, year(c), d 

the execution time 6 seconds.

if uncomment --and c not null execution time 6 or 5 seconds.

if uncomment --and d not null don't know execution time because haven't waited query finish.

why uncommenting --and d not null makes execution time soar?

have checked execution plan? money on index issue. if query using index has d included column rather indexed column it's force scan of table/index kill performance. run execution plan , without null statements, that's going point towards issue is. check index hints when this.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -