首页 > 数据库 > Oracle > 一个脑筋没转过来的insert问题
插入语句如下,由于保密缘故,相关信息已做修改:
insert into SGS.PROD_NEW
select *
from SGS.PROD
where CREATE_TIME >= to_date('2019-01-01', 'yyyy-mm-dd')
and CREATE_TIME < to_date('2020-07-01', 'yyyy-mm-dd');
这张表大概10万行数据,没有主键,没有索引。
set linesize 200; col owner for a20; col table_name for a40; col tablespace_name for a20; select owner, table_name, num_rows,TABLESPACE_NAME from dba_tables where table_name = 'PROD'; OWNER TABLE_NAME NUM_ROWS TABLESPACE_NAME -------------------- ---------------------------------------- ---------- -------------------- SGS PROD 107220 GC_TS
表的大小60M左右:
SQL> select bytes/1024/1024 MB from dba_segments where segment_name='PROD'; MB ---------- 59
第一次表插入时,跑了1个小时没跑完,看了下等待事件,一直都是direct path read,也没有阻塞,为什么那么慢,看了下执行计划是走的全表扫描,执行计划没有问题:
------------------------------------------------------------------------------------------------------ | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ------------------------------------------------------------------------------------------------------ | 0 | INSERT STATEMENT | | | | 2027 (100)| | | 1 | LOAD TABLE CONVENTIONAL | PRODNEW | | | | | |* 2 | TABLE ACCESS FULL | PROD | 106K| 67M| 2027 (1)| 00:00:01 | ------------------------------------------------------------------------------------------------------
浑水摸鱼1个小时后,想到了有没可能是大字段导致的呢?查了下,果然,MMP,有一个CLOB类型字段100G的大小。
SQL> select bytes/1024/1024/1024 GB from dba_segments where segment_name in (select segment_name from dba_lobs where table_name='PROD'); GB ---------- .000061035 104.680664
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31355629/viewspace-2702144/ ,如需转载,请注明出处,否则将追究法律责任。