SQL性能-理解读表

问题描述 投票:0回答:1

我已经开发了一份报告,执行需要超过 1 小时,因此我启用了跟踪并尝试理解下表。

下图中哪一个导致了问题。看起来 code_combinations 表导致了这个问题。如果我错了,请纠正我。请参考截图查看SQL计划。我正在寻找减少执行时间的建议。

enter image description here

SELECT gjs.user_je_source_name "JOURNAL_SOURCE",
gjc.user_je_category_name "JOURNAL_CATEGORY",
gl.currency_code,
0 AS reportingdebit,
0 AS reportingcredit,
Sum(Nvl(gl.accounted_dr, 0)) AS ledgerdebit,
Sum(Nvl(gl.accounted_cr, 0)) AS ledgercredit,
gl.code_combination_id,
gc.segment1,
gc.segment2,
gc.segment3,
gc.segment4,
gc.segment5,
gc.segment6,
gc.segment7,
gc.segment8,
gc.segment9,
gh.period_name
FROM gl_je_headers gh,
gl_je_lines gl,
gl_je_categories gjc,
gl_je_sources gjs,
gl_code_combinations gc,
gl_ledgers gl1
WHERE 1 = 1
AND gl1.ledger_id = gh.ledger_id
AND gh.je_header_id = gl.je_header_id
AND gjc.je_category_name = gh.je_category
AND gjs.je_source_name = gh.je_source
AND gl.code_combination_id = gc.code_combination_id
AND gl1.chart_of_accounts_id = gc.chart_of_accounts_id
-- AND gl1.currency_code!='USD'
AND gl1.NAME = 'Ledger1'
AND gh.period_name IN (SELECT period_name
FROM gl_periods a
WHERE 1 = 1
AND period_num BETWEEN 1 AND
(SELECT period_num
FROM gl_periods
WHERE period_name =
:p_accounting_period
AND
period_set_name =
a.period_set_name)
AND period_year IN
(SELECT period_year
FROM gl_periods
WHERE
period_name = :p_accounting_period
AND period_set_name =
a.period_set_name))
GROUP BY gjs.user_je_source_name,
gjc.user_je_category_name,
gl.currency_code,
gl.code_combination_id,
gh.period_name,
gc.segment1,
gc.segment2,
gc.segment3,
gc.segment4,
gc.segment5,
gc.segment6,
gc.segment7,
gc.segment8,
gc.segment9

寻找您的建议。

sql query-optimization
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.