本人在使用"create table as select "时发现奇怪的问题:
第一次 create table t1 nologging as select f1,f2 from t where f1='01'
其中表t的f1建立了索引,f1='01'的数据量有5638条。
花时19秒,
接着
create table t2 as select * from t1
花时1秒
请问哪位大侠能给小弟解释一下为什么会有如此大的差异。另说明一下t表有50万数据。
如何提高第一步操作的效率呢?
第一次 create table t1 nologging as select f1,f2 from t where f1='01'
其中表t的f1建立了索引,f1='01'的数据量有5638条。
花时19秒,
接着
create table t2 as select * from t1
花时1秒
请问哪位大侠能给小弟解释一下为什么会有如此大的差异。另说明一下t表有50万数据。
如何提高第一步操作的效率呢?
应该是 where f1='01' 的影响,加INDEX看看。
1、f1是建了索引的,
2、select f1,f2 from t where f1='01'的速度很快,只要1.1秒的时间
3、f1和f2字段都设置的是VARCHAR2(100)
还是那个问题,是什么原因造成的呢?
下面是我测试的结果,很快的,仅供参考:-----------------------------------------------------------------------------------------------------------------SQL> set serveroutput on size 10000;
SQL> set timing on;
SQL> select count(0) from t; COUNT(0)
----------
500000経過: 00:00:00.05
SQL> select count(0) from t where f1 = '01'; COUNT(0)
----------
5638経過: 00:00:00.01
SQL> create table t1 nologging as select f1,f2 from t where f1='01';表が作成されました。経過: 00:00:00.00
SQL> create table t2 as select * from t1;表が作成されました。経過: 00:00:00.00
SQL> select count(0) from t1; COUNT(0)
----------
5638経過: 00:00:00.00
SQL> select count(0) from t2; COUNT(0)
----------
5638経過: 00:00:00.00
SQL>-----------------------------------------------------------------------------------------------------------------