Hi,
I'm encountered with a strange situation here.
While I'm trying to run an update it's running for hours. But, when as an alternative I create a dummy table and update using it, it executes instantly.
I'm not sure what's happening.
Though, I would like to know the cause, help me with the solution. Can I use
WITH clause to fake temporary table?
(I tried using it but it seems it is not supported with UPDATE)
--running for hours
UPDATE table tab
SET (col1, col2, col3, col4)
= (SELECT col1, col2, col3, col4
FROM table_a
INNER JOIN table_b ON join_condition
INNER JOIN table_c ON join_condition
WHERE tab.id = table_a.id
);
--runs in seconds
SELECT col1, col2, col3, col4
FROM table_a
INNER JOIN table_b ON join_condition
INNER JOIN table_c ON join_condition;
--runs in seconds
CREATE TABLE data_source AS
SELECT table_a.id, col1, col2, col3, col4
FROM table_a
INNER JOIN table_b ON join_condition
INNER JOIN table_c ON join_condition;
--runs in seconds
UPDATE table tab
SET (col1, col2, col3, col4)
= (SELECT col1, col2, col3, col4
FROM data_source
WHERE tab.id = data_source.id
);
[\code]
It updates around 10,000 rows of total 30,000 rows.
+As of now I may not be able to provide any database stats (explain plan etc.). Also, it's better if I can avoid any DDL. Please bear with me.+
I'm using oracle 11g.
Thanks.