Query Optimization
the query which takes about 1 min in teradata takes over 30 mins is Oracle 11.2
Platform : Linux 64bit
UPDATE sh_store_fcasts sf
SET used = 0
where exists (select '1' from promos_to_forecast rt
WHERE sf.offer_number = rt.offer_number
AND sf.base_product_number_std = rt.base_product_number_std);
Explain plan for the query is below:
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------
Plan hash value: 2782662485
---------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------------------------------
| 0 | UPDATE STATEMENT | | 4940 | 173K| 12440 (1)| 00:02:30 |
| 1 | UPDATE | SH_STORE_FCASTS | | | | |
| 2 | NESTED LOOPS | | 4940 | 173K| 12440 (1)| 00:02:30 |
| 3 | SORT UNIQUE | | 4940 | 79040 | 7 (0)| 00:00:01 |
| 4 | INDEX FAST FULL SCAN| PROMOS_TO_FORECAST_IDX1 | 4940 | 79040 | 7 (0)| 00:00:01 |
|* 5 | INDEX RANGE SCAN | SH_STORE_FCASTS_IDX1 | 1 | 20 | 3 (0)| 00:00:01 |
Platform : Linux 64bit
UPDATE sh_store_fcasts sf
SET used = 0
where exists (select '1' from promos_to_forecast rt
WHERE sf.offer_number = rt.offer_number
AND sf.base_product_number_std = rt.base_product_number_std);
Explain plan for the query is below:
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------
Plan hash value: 2782662485
---------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------------------------------
| 0 | UPDATE STATEMENT | | 4940 | 173K| 12440 (1)| 00:02:30 |
| 1 | UPDATE | SH_STORE_FCASTS | | | | |
| 2 | NESTED LOOPS | | 4940 | 173K| 12440 (1)| 00:02:30 |
| 3 | SORT UNIQUE | | 4940 | 79040 | 7 (0)| 00:00:01 |
| 4 | INDEX FAST FULL SCAN| PROMOS_TO_FORECAST_IDX1 | 4940 | 79040 | 7 (0)| 00:00:01 |
|* 5 | INDEX RANGE SCAN | SH_STORE_FCASTS_IDX1 | 1 | 20 | 3 (0)| 00:00:01 |
0