SQL Server optimized large query with ISNULL where clause -
i have following large select query return 1.5 million rows in 08:15. need optimize query selects 290 columns , can't reduce number of columns improve speed.
select column1 ... column290 dob.table1 (isnull(column50, 1) = 1)
i have read isnull
has performance cost if used in where
clause because optimizer not use index resort scan, correct?
i trying figure out how rewrite
where (isnull(column50, 1) = 1)
i tried using cte , setting
ip_column50 = case when ip_column50 null else ip_column50 end
and rewriting query
select * cte ip_column50 = 1
but cte took longer.
i read approach
if so, consider creating computed column result if isnull(col1, 0) , index computed column , use in where-clause
but not sure how implement this. appreciated optimizing query.
thanks
you can in single query too. this.
select column1 ... column290 dob.table1 column50 = 1 or column50 null
this has potential though of becoming problematic type of catch query. check out article if have multiple criteria need check this.
http://sqlinthewild.co.za/index.php/2009/03/19/catch-all-queries/
Comments
Post a Comment