0

先週このクエリを実行しようとしましたが、7 時間経ってもまだ実行されていたため、1 日の終わりにキャンセルする必要がありました。最終結果が20,000行になるはずの800行以上しか返されませんでした..パフォーマンスを改善するためのアドバイスは大歓迎です。

どうもありがとう。

Select 
    a.entryID, g.GroupName, 
   MAX(CASE WHEN e.attributedefinitionid = 15 THEN e.AttributeValue END) AS EnglishWording, 
   MAX(CASE WHEN e.attributedefinitionid = 41 THEN e.AttributeValue END) AS GermanWording, 
   MAX(CASE WHEN e.attributedefinitionid = 64 THEN e.AttributeValue END) AS RussianWording,
   MAX(CASE WHEN e.attributedefinitionid = 91 THEN e.AttributeValue END) AS FrenchWording, 
   MAX(CASE WHEN e.attributedefinitionid = 143 THEN e.AttributeValue END) AS ItalianWording, 
   MAX(CASE WHEN e.attributedefinitionid = 160 THEN e.AttributeValue END) AS SpanishWording,
   MAX(CASE WHEN e.attributedefinitionid = 165 THEN e.AttributeValue END) AS ChineseWording,
   MAX(CASE WHEN e.attributedefinitionid = 170 THEN e.AttributeValue END) AS JapaneseWording,
   MAX(CASE WHEN h.attributedefinitionid = 17 
              THEN convert(varchar(10), h.AttributeValue, 120) 
       END) as DateA, 
   MAX(CASE WHEN h.attributedefinitionid = 557 
              THEN convert(varchar(10), h.AttributeValue, 120) 
       END) as DateO,
   MAX(CASE WHEN h.attributedefinitionid = 558 
              THEN convert(varchar(10), h.AttributeValue, 120) 
       END) as DateC,
   MAX(CASE WHEN j.attributedefinitionid = 29 THEN j.AttributeValue END) AS Warning,
   MAX(CASE WHEN l.attributedefinitionid = 23 THEN l.AttributeValue END) AS Highlight,
   MAX(CASE WHEN n.attributedefinitionid = 572 THEN n.AttributeValue END) AS Investigations,
   MAX(CASE WHEN p.attributedefinitionid = 30 THEN p.AttributeValue END) AS Comments,
   MAX(CASE WHEN s.attributedefinitionid = 39 THEN s.AttributeValue END) AS USD, 
   MAX(CASE WHEN s.attributedefinitionid = 40 THEN s.AttributeValue END) AS EUR, 
   MAX(CASE WHEN s.attributedefinitionid = 92 THEN s.AttributeValue END) AS GBP, 
   MAX(CASE WHEN s.attributedefinitionid = 450 THEN s.AttributeValue END) AS RBN, 
   MAX(CASE WHEN s.attributedefinitionid = 451 THEN s.AttributeValue END) AS JPY, 
   MAX(CASE WHEN s.attributedefinitionid = 552 THEN s.AttributeValue END) AS HK$,
   MAX(CASE WHEN u.attributeDefinitionID = 142 THEN u.attributeValue END) AS [Status]
From 
   Entry as a
inner join 
   entrycategory as b on b.entryid = a.entryid
inner join 
   category as c on c.categoryid = b.categoryid 
inner join 
   [Group] as g on g.groupID = c.groupID
left outer join 
   EntryAttribute AS d on d.entryID = A.entryid
left outer join 
   attributestring AS e on e.attributeid = d.attributeid
left outer join 
   EntryAttribute as f on f.EntryID = a.EntryID
left outer join 
   AttributeDateTime as h on h.AttributeID = f.AttributeID
left outer join 
   EntryAttribute as i on i.EntryID = a.EntryID
left outer join 
   AttributeString as j on j.AttributeID = i.AttributeID
left outer join 
   EntryAttribute as k on k.EntryID = a.EntryID
left outer join 
   AttributeString as l on l.AttributeID = k.AttributeID
left outer join 
   EntryAttribute as m on m.EntryID = a.EntryID
left outer join 
   AttributeString as n on n.AttributeID = m.AttributeID
left outer join 
   EntryAttribute as o on o.EntryID = a.EntryID
left outer join 
   AttributeString as p on p.AttributeID = o.AttributeID
inner join 
   EntryAttribute AS r on r.entryID = A.entryid
inner join 
   attributestring AS s on s.attributeid = r.attributeid
left outer join 
   EntryAttribute as t on t.EntryID = a.EntryID
left outer join 
   AttributeString as u on u.AttributeID = t.AttributeID
Group by 
   a.entryID, g.GroupName
4

1 に答える 1