Featured post
Why do statistics get out of date so quickly in SQL Server? -
we have complex sql update query gets run few times month. of time seems run fast, on databases, takes long time. after running "update statistics" on tables involved, update runs again. set nightly task calls update statistics on tables in database. didn't seem fix problem. we're still ending having run "update statistics" manually each time. why statistics go stale quickly?
here's approximately query looks like:
update datatablea set datatablea.indexedcolumn1 = 123456789, datatablea.flag1 = 1 datatablea (index(ix_datatablea)) inner join groupingtablea on groupingtablea.foreignkey1 = groupingtablea.primarykey inner join lookuptablea on datatablea.foreignkey3 = lookuptablea.primarykey left outer join groupingtableb on datatablea.indexedcolumn2 = groupingtableb.indexedcolumn2 groupingtableb.indexedcolumn1 = 123456789 , datatablea.indexedcolumn1 null , datatablea.indexedcolumn2 in ( ... 300 entries here ... ) , datatablea.deleted = 0 , groupingtablea.date <= groupingtableb.enddate , groupingtablea.date >= dateadd(month, -1, groupingtableb.startdate) , lookuptablea.column2 = 1 , datatablea.status1 in (1, 3) , datatablea.status2 not in (1, 3, 9)
datatablea contains millions of rows.
groupingtablea , groupingtableb each contain tens of thousands of rows.
lookuptablea contains dozens of rows.
index ix_datatablea index on (indexedcolumn1 asc, indexedcolumn2 asc)
i don't think statistics matter if forcing use specific index (with (index(ix_datatablea))
are sure know better optimizer?
i start looking @ execution plan fast update , slow update. also, number of records being updated comparable fast/slow queries?
- Get link
- X
- Other Apps
Comments
Post a Comment