データの場合は何千ものデータを含むselectステートメントがありますが、実行時間は非常に遅く、15分以上かかる場合があります。私はこのselect文の実行時間を改善することができます。非常に遅いoracle選択ステートメント
select a.levelP,
a.code,
a.descP,
(select nvl(SUM(amount),0) from ca_glopen where code = a.code and acc_mth = '2016') ocf,
(select nvl(SUM(amount),0) from ca_glmaintrx where code = a.code and to_char(doc_date,'yyyy') = '2016' and to_char(doc_date,'yyyymm') < '201601') bcf,
(select nvl(SUM(amount),0) from ca_glmaintrx where jum_amaun > 0 and code = a.code and to_char(doc_date,'yyyymm') = '201601') debit,
(select nvl(SUM(amount),0) from ca_glmaintrx where jum_amaun < 0 and code = a.code and to_char(doc_date,'yyyymm') = '201601') credit
from ca_chartAcc a
where a.code is not null
order by to_number(a.code), to_number(levelP)
アップあなたの主な問題は、あなたのサブクエリのほとんどはあなたの日付にいくつかの厄介なものも含めて検索条件、上の機能を使用することで、私のクエリとresult.TQ
はい:サブクエリは結果行ごとに実行されている可能性があります。ええ、最初のものを除くすべてがインデックス(テーブルスキャン)を使用する可能性は低いです。それと、あなたの 'ORDER BY 'はすべての行を変換する必要があるので、インデックスを使うこともできません。 –
クエリヒントを使用して適切なインデックスを作成しようとしました –
これを変更しようとします –