我从一个表中查询数据(大约8300万行)并将其插入到同一模式中的另一个表中时,响应时间非常长。这需要将近一个半小时。查询如下所示:
INSERT
INTO TABLE_A
(
DIM_KEY,
CLIENT_KEY,
CONSUMER_DIM_KEY,
PRCS_WK
)
(
((
(SELECT DIM_KEY,
client_KEY,
consumer_dim_key,
prcs_WK
FROM
(*SELECT DISTINCT DIM_KEY,
client_KEY,
prcs_WK,
consumer_dim_key,
SUM(SALE_AMOUNT) OVER(PARTITION BY CONSUMER_DIM_KEY) AS SALE_AMOUNT
FROM FACT_TABLE
WHERE DIM_KEY = '300067'
AND CRITERIA_ID = '1234'
AND IS_EXISTS = 'N'*
)
WHERE SALE_AMOUNT > 0
)
UNION
(SELECT DIM_KEY,
client_KEY,
consumer_dim_key,
prcs_WK
FROM
(*SELECT DISTINCT DIM_KEY,
client_KEY,
prcs_WK,
consumer_dim_key,
SUM(SALE_AMOUNT) OVER(PARTITION BY CONSUMER_DIM_KEY) AS SALE_AMOUNT
FROM FACT_TABLE
WHERE DIM_KEY = '300067'
AND CRITERIA_ID = '1235'
AND IS_EXISTS = 'N'*
)
WHERE SALE_AMOUNT > 0
))
UNION
(SELECT DIM_KEY,
client_KEY,
consumer_dim_key,
prcs_WK
FROM
(*SELECT DISTINCT DIM_KEY,
client_KEY,
prcs_WK,
consumer_dim_key,
SUM(SALE_AMOUNT) OVER(PARTITION BY CONSUMER_DIM_KEY) AS SALE_AMOUNT
FROM FACT_TABLE
WHERE DIM_KEY = '300067'
AND CRITERIA_ID = '1236'
AND IS_EXISTS = 'N'*
)
WHERE SALE_AMOUNT > 0
))
)
此处所有表都存在于同一模式中。 标记为*的查询返回行数:
Sub-query 1: 80 million rows Sub-query 2: 3.1 million rows Sub-query 3: 0.2 million row
答案 0 :(得分:3)
alter table YOUR_TABLE nologging;
commit_wait
, commit_logging tips
这是我可以在没有解释计划的情况下给你的所有建议。