パフォーマンス上の問題により、以下のクエリはもう機能しません。私は左の結合がほとんどありません。SQLによるパフォーマンスの向上(左結合?)
主な問題は、異なる値から最大値を取得するために、同じテーブルで3つの「MAX」を検索していることです。
これを最適化する方法はありますか?
SELECT B.BG_BUG_ID "Defect ID" ,
BG_USER_TEMPLATE_16 "Status" ,
BG_USER_TEMPLATE_12 "Priority" ,
BG_USER_TEMPLATE_11 "Severity",
BG_DETECTION_DATE "Detectado em",
BG_USER_TEMPLATE_01 "Fase Detecção",
BG_USER_TEMPLATE_10 "Fornecedor",
BG_USER_TEMPLATE_18 "Area Responsavel",
BG_RESPONSIBLE "Assinado para",
BG_USER_TEMPLATE_09 "Sistema Correção",
BG_USER_TEMPLATE_17 "Ambiente",
BG_USER_TEMPLATE_19 "Causa Raiz",
c.rtt_Time "RTT time",
BG_CLOSING_DATE "Data de Fechamento",
BG_USER_17 "Data Alteração Status",
al_description "Caminho Test Plan",
BG_SUMMARY "Descrição Resumida",
B.Fixed_Time "Fixed time",
BG_DETECTED_BY "Detectado por",
BG_USER_TEMPLATE_15 "Motivo",
BG_USER_TEMPLATE_04 "Motivo Status Waiting",
BG_USER_01 "Pendente com",
A.reopen_Time "lAST REOPEN DATE",
BG_TARGET_RCYC "Target Cycle",
R_CYCLE.rcyc_name "Target Cycle",
REL_NAME "Target Release",
BG_TARGET_REL "Target Release" ,
BG_USER_TEMPLATE_08 "Tipo",
BG_USER_TEMPLATE_07 "Tipo de Solicitação",
BG_USER_TEMPLATE_06 "Status da Solicitação",
BG_USER_04 "Contador Fixing",
BG_USER_26 /*Defect.Reaberturas Validas*/ "Contador Reopened",
BG_USER_TEMPLATE_20 "CTs Impactados",
BG_USER_20 "Data Prevista Correção",
BG_USER_23 "Macro Processo",
BG_USER_TEMPLATE_03 "Defeito Associado"
FROM BUG B LEFT JOIN ALL_LISTS AL
ON B.bg_subject = AL.al_item_id
LEFT JOIN (SELECT bg_bug_id, max(au_time) reopen_Time
from
bug,audit_log, audit_properties
where AU_ENTITY_TYPE='BUG'
and au_entity_id=bg_bug_id
AND AP_ACTION_ID=au_ACTION_ID
AND AP_FIELD_NAME='BG_USER_TEMPLATE_16'
AND AP_NEW_VALUE='Reopened'
group by bg_bug_id) A
ON A.BG_BUG_ID=B.BG_BUG_ID
LEFT JOIN (SELECT bg_bug_id, max(au_time) fixed_time
from
bug,audit_log, audit_properties
where AU_ENTITY_TYPE='BUG'
and au_entity_id=bg_bug_id
AND AP_ACTION_ID=au_ACTION_ID
AND AP_FIELD_NAME='BG_USER_TEMPLATE_16'
AND AP_NEW_VALUE='Ready to Application'
group by bg_bug_id) B
ON A.BG_BUG_ID=B.BG_BUG_ID
LEFT JOIN (SELECT bg_bug_id, max(au_time) rtt_time
from
bug,audit_log, audit_properties
where AU_ENTITY_TYPE='BUG'
and au_entity_id=bg_bug_id
AND AP_ACTION_ID=au_ACTION_ID
AND AP_FIELD_NAME='BG_USER_TEMPLATE_16'
AND AP_NEW_VALUE='Ready to Test'
group by bg_bug_id) C
ON A.BG_BUG_ID=B.BG_BUG_ID
left join RELEASE_CYCLES R_CYCLE
on b.BG_TARGET_RCYC = R_CYCLE.rcyc_id
Where 1=1
and BG_TARGET_RCYC= 1085
Order by B.BG_BUG_ID
あなたが古い、JOIN構文を使用していないことにより、簡単にパフォーマンスの向上を得ることができます:私は言ったにも関わらず
は、ここでは内部で刺しが参加します。 "FROM bug、audit_log、audit_properties"を使うと、そのJOINをCROSS JOINにすることができます。そしてあなたはそれを3回やっています。ここで読んでください:http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/08/bad-habits-to-kick-using-old-style-joins.aspx –
"アプリケーションライフサイクル管理" : 火で殺します。ヒント:共通サブクエリの削除。 – wildplasser