Home » SQL & PL/SQL » SQL & PL/SQL » Enforcing a particular execution plan (Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production)
Enforcing a particular execution plan [message #635258] Wed, 25 March 2015 11:41 Go to next message
manubatham20
Messages: 566
Registered: September 2010
Location: Seattle, WA, USA
Senior Member

Hi,

Please consider below statement. The problem I am facing is while inserting, if I am just doing a simple select, it's giving all rows of result in 12 to 15 seconds, while if I am trying to insert those rows in a table, it's taking like 4 to 5 minutes.

The reason is different execution plans (please see attached), I tried to fix it using the hints I know (no_merge, ordering), but seems like its something related to dynamic partition pruning.
Can you please help me fixing it (using hints) or any other alternative should I try. This is a Test environment, DB statistics are up to date when it was last copied from Production, and no data changes in DB.

INSERT INTO A_TABLE (TOOL_NAME,
                     SHIFT_START_DT,
                     WARN_ALARM_COUNT,
                     HALT_ALARM_COUNT)
   WITH tmp_distinct_wafer_metrics_gtt
        AS (SELECT DISTINCT tool_name, shift_start_dt
              FROM temp_manu1),
        tmp_alert_count
        AS (  SELECT wm_ps.tool_name,
                     wm_ps.shift_start_dt,
                     SUM (DECODE (TRIM (kpiv_alarm.severity), 'WARN', 1, 0))
                        warn_alarm_count,
                     SUM (DECODE (TRIM (kpiv_alarm.severity), 'HALT', 1, 0))
                        halt_alarm_count
                FROM tbl_fiscal_calendar fiscal_cal
                     INNER JOIN tmp_distinct_wafer_metrics_gtt wm_ps
                        ON (fiscal_cal.startdatetime = wm_ps.shift_start_dt)
                     LEFT OUTER JOIN wafnrm_owner.kpiv_alarm kpiv_alarm
                        ON (    wm_ps.tool_name = kpiv_alarm.mach
                            AND kpiv_alarm.pdatetime BETWEEN TO_DATE (
                                                                wm_ps.shift_start_dt,
                                                                'YYYYMMDD HH24MISS')
                                                         AND   TO_DATE (
                                                                  wm_ps.shift_start_dt,
                                                                  'YYYYMMDD HH24MISS')
                                                             + 1)
                     INNER JOIN
                     WLOSSITE_OWNER.TBL_XSITE_EQP_STATE_CHANGES xsite_eqp_info
                        ON (    (   xsite_eqp_info.state LIKE '%PROD%'
                                 OR xsite_eqp_info.state LIKE '%IDLE%')
                            AND xsite_eqp_info.FAC = 'NRM'
                            AND KPIV_ALARM.MACH = XSITE_EQP_INFO.EQP_NAME
                            AND KPIV_ALARM.PDATETIME BETWEEN XSITE_EQP_INFO.STATE_START_DT
                                                         AND XSITE_EQP_INFO.STATE_END_DT
                            AND xsite_eqp_info.ACTUAL_STATE_START_DT_KEY =
                                   fiscal_cal.fiscalcalendar_key)
            GROUP BY wm_ps.tool_name, wm_ps.shift_start_dt)
   SELECT a.tool_name,
          a.shift_start_dt,
          NVL (b.warn_alarm_count, 0),
          NVL (b.halt_alarm_count, 0)
     FROM tmp_distinct_wafer_metrics_gtt a
          LEFT OUTER JOIN tmp_alert_count b
             ON (    a.tool_name = b.tool_name
                 AND a.shift_start_dt = b.shift_start_dt);


P.S I can't provide data to regenerate problem.

Thanks,
Manu
Re: Enforcing a particular execution plan [message #635259 is a reply to message #635258] Wed, 25 March 2015 11:44 Go to previous messageGo to next message
Roachcoach
Messages: 1576
Registered: May 2010
Location: UK
Senior Member
Are you doing the select in a GUI and just getting the first couple of hundred rows back, per chance?
Re: Enforcing a particular execution plan [message #635260 is a reply to message #635259] Wed, 25 March 2015 11:46 Go to previous messageGo to next message
manubatham20
Messages: 566
Registered: September 2010
Location: Seattle, WA, USA
Senior Member

Nope, I am not just testing in GUI (Toad) only. I implemented the insert in the packaged code. Well, it's just 330 rows overall, that I am getting as the result of execution. So I think testing in GUI doesn't matter.
Re: Enforcing a particular execution plan [message #635261 is a reply to message #635260] Wed, 25 March 2015 11:56 Go to previous message
manubatham20
Messages: 566
Registered: September 2010
Location: Seattle, WA, USA
Senior Member

I found something here..

Bloom filters

It says:

Quote:
Bloom filters are not used in DML statements: Bug 13801198 says that a simple two table join shows use of Bloom filter/pruning when running as a query and not when running as part of a INSERT as SELECT. The performance delta is 4:24 vs 0:24.


Really... very strange, if it's real.

Thanks,
Manu
Previous Topic: need conditional quantity insert into table
Next Topic: request for solution
Goto Forum:
  


Current Time: Wed Apr 24 11:31:15 CDT 2024