Uploaded image for project: 'CFA MX '
  1. CFA MX
  2. CFAMX-10244

Improve performance of SalesItemMetricDetail query

    Details

      Description

      This query was determined to be using 30% of the CPU resources on the SQL server during non-EOM timeframes:

      exec sp_executesql N'SELECT this_.SalesItemMetricDetailId as SalesIte1_121_0_, this_.SalesItemId as SalesIte2_121_0_, 
      this_.IntervalStart as Interval3_121_0_, this_.LastYearTransactionCount as LastYear4_121_0_, this_.ManagerTransactionCount as ManagerT5_121_0_, 
      this_.RawTransactionCount as RawTrans6_121_0_, this_.SystemTransactionCount as SystemTr7_121_0_, this_.ServiceType as ServiceT8_121_0_, 
      this_.MgrDetailsChanged as MgrDetai9_121_0_, this_.ForecastId as ForecastId121_0_ 
      FROM Forecasting.SalesItemMetricDetail this_ 
      WHERE ((this_.ForecastId = @p0 and this_.IntervalStart >= @p1) 
      and this_.IntervalStart < @p2)',N'@p0 bigint,@p1 datetime,@p2 datetime',@p0=6130758,@p1='2020-05-30 00:00:00',@p2='2020-05-31 00:00:00'
      

      Suggestions from SQL optimization consultant:

      1. Create a new Non Clustered index on columns (ForecastID, IntervalStart) similar to the index on Forecasting.InventoryItemMetricDetail table. As seen by Missing Index hint from execution plan above, adding this index will improve performance by 98%
      2. Currently there is an index on ForecastID column. We need to analyse the code to see if there are times we search Forecasting.SalesItemMetricDetail only using the “ForecastID” column. Looking at the usage, it seems that we always search this table by “ForecastID” and “IntervalStart” columns. In this case we can delete the index : “IX_SalesItemMetricDetail_forecastId”, or convert this to add “IntervalStart” column as well as mentioned above.

        Attachments

          Issue Links

          There are no Sub-Tasks for this issue.

            Activity

              People

              • Assignee:
                Corey.Amend Corey Amend (Inactive)
                Reporter:
                Corey.Amend Corey Amend (Inactive)
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  PagerDuty

                  Error rendering 'com.pagerduty.jira-server-plugin:PagerDuty'. Please contact your Jira administrators.