我有以下的Oracle查询,执行速度很快(几秒钟内完成):
这太慢了。非常缓慢,以至于交易超时(在我的情况下超过30秒)。您有任何想法为什么这么慢,并且如何进行优化吗?
select contract_id_fk as ct,
max(trip_id) as tid,
max(consumed_mileage) as cum
from trip
where to_date > to_date('20-12-2016','DD-MM-YYYY')
and contract_id_fk is not null
and vehicle_id_fk is not null
and trip_stop_status is null
group by contract_id_fk
“trip”表有大量行(超过2000万)。现在,我想使用以下方式将此查询结果插入表中:
INSERT INTO lst
select contract_id_fk as ct,
max(trip_id) as tid,
max(consumed_mileage) as cum
from trip
where to_date > to_date('20-12-2016','DD-MM-YYYY')
and contract_id_fk is not null
and vehicle_id_fk is not null
and trip_stop_status is null
group by contract_id_fk
这太慢了。非常缓慢,以至于交易超时(在我的情况下超过30秒)。您有任何想法为什么这么慢,并且如何进行优化吗?
CTAS
操作呢? - Migs Isip