SELECT 语句需要数小时才能执行

SELECT statement takes hours to execute

我正在尝试 运行 这个 SELECT 语句,但我需要几个小时才能执行。我还在这些表上创建了索引。

SELECT DISTINCT 
    j.Name AS State,
    l.DisplayName AS ServiceCenter,
    l.JurisdictionID,
    e.LocationID,
    ConvictionStateID AS RegionId,
    FeeGroupID,
    e.VehicleID ,
    ServiceDate,
    evd.EventlogID,
    v.ClientID,
    e.EventLogServiceID,
    evd.EventlogDetailID,
    EvtDT AS EventDate,
    EvtVal AS EventValue,
    evd.EventLogCodeID,
    UPPER(SerialNumber) AS SerialNumber,
    UPPER(RelayNum) AS RelayNumber,
    edp.FileName,
    GPSLatitude
FROM
    [MM\PLUSREPORT5].lsa_plus_jur_nico.dbo.EventLogDetail evd
INNER JOIN 
    [MM\PLUSREPORT5].lsa_plus_jur_nico.dbo.EventLog e ON evd.EventlogID = e.EventlogID
INNER JOIN 
    [MM\PLUSREPORT5].lsa_plus_jur_nico.dbo.Vehicle v ON e.VehicleID = v.VehicleID
INNER JOIN 
    [MM\PLUSREPORT5].lsa_plus_jur_nico.dbo.Client c ON v.ClientID = c.ClientID
INNER JOIN 
    [MM\PLUSREPORT5].lsa_plus_base.dbo.Location l ON e.LocationID = l.LocationID
INNER JOIN 
    [MM\PLUSREPORT5].lsa_plus_base.dbo.Jurisdiction j ON l.JurisdictionID = j.JurisdictionID
LEFT JOIN 
    [MM\PLUSREPORT5].lsa_plus_jur_nico.dbo.EventLogDetailPhoto edp ON evd.EventLogDetailId = edp.EventLogDetailId

Excution plan ,也嵌在下面。

您没有得到任何并行度和排序 popping-up。

检查您的索引是否配置为 DESC 顺序。

索引反向扫描的一个限制是它们不能并行。

如果可能,也尝试删除 DISTINCT,这会增加相同的限制。