I have an SQL database server and 2 databases under it with the same structure and data. I run the same sql query in two databases, one of them takes longer and the other in less than 50% of cases. They both have different implementation plans.
The request for the presentation is as follows:
SELECT DISTINCT i.SmtIssuer, i.SecID, ra.AssetNameCurrency AS AssetIdCurrency, i.IssuerCurrency, seg.ProxyCurrency, shifts.ScenarioDate, ten.TenorID, ten.Tenor, shifts.Shift, shifts.BusinessDate, shifts.ScenarioNum FROM dbo.tblRrmIssuer AS i INNER JOIN dbo.tblRrmSegment AS seg ON i.Identifier = seg.Identifier AND i.SegmentID = seg.SegmentID INNER JOIN dbo.tblRrmAsset AS ra ON seg.AssetID = ra.AssetID INNER JOIN dbo.tblRrmHistSimShift AS shifts ON seg.Identifier = shifts.Identifier AND i.SegmentID = shifts.SegmentID INNER JOIN dbo.tblRrmTenor AS ten ON shifts.TenorID = ten.TenorID INNER JOIN dbo.tblAsset AS a ON i.SmtIssuer = a.SmtIssuer INNER JOIN dbo.tblRrmSource AS sc ON seg.SourceID = sc.SourceID WHERE (a.AssetTypeID = 0) AND (sc.SourceName = 'CsVaR') AND (shifts.SourceID = (SELECT SourceID FROM dbo.tblRrmSource WHERE (SourceName = 'CsVaR')))
What I have already tried is to rebuild and reorganize the index in the table (tblRRMHistSimShifts - this table has more than 2 million records), it is checked for locks or other background processes or errors on the server, the maximum degree of parallelism for the server is 0.
Is there anything else you can suggest to fix this problem?
Divya source share