Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to correct poor performance in T-SQL view
    primarykey
    data
    text
    <p>I have an ASP.NET MVC application that is using a T-SQL view I created as part of its data model. I'm able to pull in the view data but I'm getting very poor performance.</p> <p>If I do a <code>SELECT *</code> on the view in SQL Server 2008 it takes over 20 minutes to return all 187,101 of the rows.</p> <p>If I do a <code>SELECT TOP 1000000</code> on the view I get the same 187,101 rows returned in 2 seconds.</p> <p>So I included the <code>TOP</code> statement in my view design to try to get better performance in the ASP.NET MVC application but it still takes ~6 seconds to load the results in a WebGrid.</p> <p>There's obviously something in my view design that is killing performance but I'm not sure how to fix it. I read about clustered index views but I can't schema bind the view because the tables need to be able to be modified.</p> <p>Here is the <code>SELECT</code> statement I used to create my view:</p> <pre><code>SELECT TRD.Description AS Pbm, MV.ExtractHistoryMemberValueId, MV.FieldDescription, MV.FieldValue, HM.ExtractHistoryMemberId, HM.CaseNum, HM.CertNum, HM.ClmtNum, HM.PlanNum, EH.ExtractHistoryId, EH.ExtractDate FROM OutgoingAccumulators.ExtractHistoryMemberValues AS MV INNER JOIN OutgoingAccumulators.ExtractHistoryMembers AS HM ON (MV.ExtractHistoryMember = HM.ExtractHistoryMemberId) INNER JOIN OutgoingAccumulators.ExtractHistories AS EH ON (HM.ExtractHistory = EH.ExtractHistoryId) INNER JOIN OutgoingAccumulators.Extracts AS EX ON (EH.Extract = EX.ExtractId) INNER JOIN Accumulators.Interfaces AS INF ON (EX.Interface = INF.InterfaceId) INNER JOIN Accumulators.TradingPartners AS TRD ON (INF.TradingPartner = TRD.TradingPartnerId) </code></pre> <p>Here is an image of the view design:</p> <p><img src="https://i.stack.imgur.com/W8u3x.png" alt="view"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload