为什么从同一个表中选择特定列会显着降低查询性能?

时间:2017-05-19 21:36:36

标签: sql sql-server performance tsql database-administration

我有SELECT语句查询tblQuotes中的列。为什么我选择列a.ProducerCompositeCommissiona.CompanyCompositeCommission,然后查询永久旋转。

包含和不包含这些列的执行计划都是IDENTICAL!

如果我将它们评论出来 - 那么它会带来1秒的结果。

SELECT 
    a.stateid risk_state1,
    --those columns slows down performance 
    a.ProducerCompositeCommission,
    a.CompanyCompositeCommission,
    GETDATE() runDate
FROM
    tblQuotes a 
INNER JOIN
    lstlines l ON a.LineGUID = l.LineGUID
INNER JOIN 
    tblSubmissionGroup  tsg ON tsg.SubmissionGroupGUID = a.SubmissionGroupGuid
INNER JOIN  
    tblUsers u ON u.UserGuid = tsg.UnderwriterUserGuid 
INNER JOIN  
    tblUsers u2 ON u2.UserGuid = a.UnderwriterUserGuid  
LEFT OUTER JOIN   
    tblFin_Invoices tfi ON tfi.QuoteID = a.QuoteID AND tfi.failed <> 1     
INNER JOIN 
    lstPolicyTypes lpt ON lpt.policytypeid = a.policytypeid
INNER JOIN 
    tblproducercontacts prodC ON prodC.producercontactguid = a.producercontactguid
INNER JOIN 
    tblProducerLocations pl ON pl.producerlocationguid = prodc.producerlocationguid
INNER JOIN 
    tblproducers prod ON prod.ProducerGUID = pl.ProducerGUID
LEFT OUTER JOIN  
    Catalytic_tbl_Model_Analysis aia ON aia.ImsControl = a.controlno 
                                     AND aia.analysisid = (SELECT TOP 1 tma2.analysisid 
                                                           FROM Catalytic_tbl_Model_Analysis tma2 
                                                           WHERE tma2.imscontrol = a.controlno)
LEFT OUTER JOIN  
    Catalytic_tbl_RDR_Analysis rdr ON rdr.ImsControl = a.controlno 
                                   AND rdr.analysisid = (SELECT TOP 1 tma2.analysisid 
                                                         FROM Catalytic_tbl_RDR_Analysis tma2 
                                                         WHERE tma2.imscontrol = a.controlno)
LEFT OUTER JOIN  
    tblProducerContacts mnged ON mnged.producercontactguid = ProdC.ManagedBy
LEFT OUTER JOIN  
    lstQuoteStatusReasons r1 ON r1.id = a.QuoteStatusReasonID
WHERE      
    l.LineName = 'EARTHQUAKE'  
    AND CAST(a.EffectiveDate AS DATE) >= CAST('2017-01-01' AS DATE) 
    AND CAST(a.EffectiveDate AS DATE) <=  CAST('2017-12-31' AS DATE)
ORDER BY
    a.effectiveDate

执行计划可在此处找到: https://www.brentozar.com/pastetheplan/?id=rJawDkTx-

我运行了sp_help,这就是我所看到的:

enter image description here

enter image description here

这些专栏究竟出了什么问题? 我不会在JOIN或其他任何东西中使用它们。为什么这样的行为?

表格大小:

enter image description here

tblQuotes

上的索引

enter image description here

0 个答案:

没有答案