sql server 2008 r2 - SQL Request time suddenly increase -


i have sql request executes less 1,5s. sometimes, takes more 30s , behaviour last hours.

here actual request :

set dateformat ymd;   set transaction isolation level read uncommitted;   select  categories.id categoryid,      (       case when verybigchildtable.type = 9               categories.name     else          null     end     ) categoryname,      os1.id,     os1.startdateutc,     verybigchildtable.startdateutc startdateutcsp,     categories.client_id,     verybigchildtable.articlescriptarticlesperror_articlesp_id failedstep,      verybigchildtable.[order] position,     (       case when categories.id null                  ( cast(tsheaders.id varchar(3)) + '__' + cast(os1.id varchar(15) ))         else     ( cast(categories.id varchar(3)) + '_' + cast(os1.id varchar(15) ))     end )      groupkey,     (       case when verybigchildtable.type = 9                tsheaders.currentname     else          null     end     ) ,      spheaders.id,  stuff((     select '|' + articlecategories.name     articlecategories     inner join articlecategoryarticlescript      on articlecategoryarticlescript.bigtable_id = os1.id     , articlecategoryarticlescript.articlecategories_id = articlecategories.id     xml path('')),1,1,'')  bigtable os1 inner join verybigchildtable on verybigchildtable.articlescript_id = os1.id inner join tsheaders on tsheaders.id = os1.tsarticle_id inner join spheaders on spheaders.id = verybigchildtable.spheader_id inner join categories on categories.tsheader_id = os1.tsarticle_id left outer join articlenetworks on articlenetworks.articlesparticlenetwork_articlenetwork_id = verybigchildtable.id  os1.startdateutc >= '2015-06-18 10:12:15'   , os1.startdateutc <= '2015-06-19 10:12:15'   , tsheaders.id in (319,318,322,323,324,326,328,343,345,346,347,550,552,561,565,595,612,613)   , categories.id in (494,491,484,487,511,235,241,245,265,539,540,242,236,239,240,267,268,269)  

this query returns 20k line.

verybigchildtable 260 millions line table , bigtable 60 millions line table. other tables small (less 2k line).

my configuration : sql server 2008 r2 (mirrored) on windows 2008 server, xeon 16 cores , 32gb ram.

what may cause request run more 30 s ? (knowing did not found indexation task during period)

what can optimize request ?

all remarks welcome.

it have many causes.

  • many other processes running in parallel , have cpu pressure. can check is_idle flag example: select * sys.dm_os_schedulers scheduler_id <= 256
  • you may have memory pressure due other bigger queries. can check current memory allocations select * sys.dm_exec_query_memory_grants. maybe you'll see more queries requesting memory. can take @ select * sys.dm_os_process_memory.
  • you may try recompile query using option(recompile) @ end of query new query plan fits current situation.

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -