1

I have the following query to be executed for my project:

SELECT fcr.request_id,
             DECODE
                (fcpt.user_concurrent_program_name,
                 'Report Set', fcr.description,
                 'Request Set Stage', fcr.description,
                 fcpt.user_concurrent_program_name
                ) user_concurrent_program_name,
             fcr.description, fcr.argument_text, fcr.concurrent_program_id,
             fcr.parent_request_id, fcr.actual_start_date,
             fcr.actual_completion_date,
             ROUND (  (fcr.actual_completion_date - fcr.actual_start_date)
                    * 24
                    * 60,
                    4
                   ) runtime,
             DECODE (fcr.phase_code, 'C', 'No Schedule') program_status,
             fu.user_name, frt.responsibility_name, fcr.logfile_name
        FROM apps.fnd_concurrent_requests@db_link fcr,
             apps.fnd_concurrent_programs_tl@db_link fcpt,
             apps.fnd_user@db_link fu,
             apps.fnd_responsibility_tl@db_link frt
       WHERE fcr.concurrent_program_id = fcpt.concurrent_program_id
         AND fcr.requested_by = fu.user_id
         AND fcr.responsibility_id = frt.responsibility_id
         AND fcr.responsibility_application_id = frt.application_id
         AND fcr.actual_completion_date >= (SELECT MAX (alert_logged_time)
                                          FROM allen.main_table
                                         WHERE program_status = 'No Schedule')
         AND fcr.phase_code = 'C';

But the above query takes too long to run. When I give the corresponding time as input, instead of

SELECT MAX (alert_logged_time) 
FROM allen.main_table 
WHERE program_status = 'No Schedule'

I get the output very soon even. why is that so? Anyway to rectify this?

4

3 に答える 3

1

サブクエリは Oracle のスカラー サブクエリ キャッシング機能の対象となるため、パフォーマンスが低下する理由は、次のいずれか (または両方) でインデックスが見つからない可能性があると思われます。

  • allen.main_table.program_status
  • allen.main_table.alert_logged_time
于 2013-06-19T09:44:16.927 に答える
1

代わりに結合を使用することができます

SELECT fcr.request_id,
             DECODE
                (fcpt.user_concurrent_program_name,
                 'Report Set', fcr.description,
                 'Request Set Stage', fcr.description,
                 fcpt.user_concurrent_program_name
                ) user_concurrent_program_name,
             fcr.description, fcr.argument_text, fcr.concurrent_program_id,
             fcr.parent_request_id, fcr.actual_start_date,
             fcr.actual_completion_date,
             ROUND (  (fcr.actual_completion_date - fcr.actual_start_date)
                    * 24
                    * 60,
                    4
                   ) runtime,
             DECODE (fcr.phase_code, 'C', 'No Schedule') program_status,
             fu.user_name, frt.responsibility_name, fcr.logfile_name
        FROM apps.fnd_concurrent_requests@aadsp_to_acptr fcr,
             apps.fnd_concurrent_programs_tl@aadsp_to_acptr fcpt,
             apps.fnd_user@aadsp_to_acptr fu,
             apps.fnd_responsibility_tl@aadsp_to_acptr frt,
             (SELECT MAX (alert_logged_time) as max_time
              FROM allen.main_table
              WHERE program_status = 'No Schedule')  SQ
       WHERE fcr.concurrent_program_id = fcpt.concurrent_program_id
         AND fcr.requested_by = fu.user_id
         AND fcr.responsibility_id = frt.responsibility_id
         AND fcr.responsibility_application_id = frt.application_id
         AND fcr.actual_completion_date >= SQ.max_time
         AND fcr.phase_code = 'C';
于 2013-06-19T09:46:26.757 に答える