Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

Performance tuning

$
0
0

I have question, in what order we need to place the tables in where clause if we have options. 

In what order the filtering happens in a SQL Query in general.. I believe it starts from the first table join in FROM clause (assuming no where condition) 

I have created indexes and stats as suggested by the adviser, still the query is running for hours.

I am using SQLServer 2016

The rec count is DBIntermediate is 4Million and DBdetail is 50million and in other table it is just less than 500rec

select

..

..

..

from DBIntermediate tfn join DBdetail mdd ON mdd.orgId = tfn.OrgId and mdd.RepID = tfn.RepID and isnull(tfn.ProID,mdd.ProID) = mdd.ProID and --22% cost mdd.EvaluationType = tfn.EvaluationType and mdd.DateOfService BETWEEN tfn.FromDate AND tfn.ToDate

join MSMapping msm ON msm.MeasureId = mdd.MeasureId and msm.MeasureUsage = mdd.EvalType

join DBMsplMapping dmsm ON dmsm.MeasureId = msm.MeasureId

group by tfn.id ,tfn.RepID ,tfn.FromDate ,tfn.ToDate ,tfn.t ,tfn.ProID ,mdd.MeasureId ,tfn.EvaluationType ,msm.MeasureType ,msm.HighPriority ,msm.cmid ,tfn.ccount



Neil






Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>