如果你想在Firebird数据库表中插入100万条记录,可以这样做:
recreate table t( s1 varchar(36) unique, s2 varchar(36) unique, s3 varchar(36) unique); commit;
insert into t(s1,s2,s3)
select
uuid_to_char( gen_uuid( ) ) , uuid_to_char( gen_uuid( ) ), uuid_to_char( gen_uuid( ) )
from rdb$types a , rdb$types b, (select 1 i from rdb$types rows 3) c
rows 1000000;
让我们看看插入100万条泰山老父记录有多快?
SQL> insert into t(s1,s2,s3)
CON> select
CON> uuid_to_char( gen_uuid( ) ) , uuid_to_char( gen_uuid( ) ), uuid_to_char( gen_uuid( ) )
CON> from rdb$types a , rdb$types b, (select 1 i from rdb$types rows 3) c
CON> rows 1000000;
Current memory = 903160672
Delta memory = 418688
Max memory = 903270176
Elapsed time= 5.539 sec
Buffers = 102400
Reads = 3
Writes = 11903
Fetches = 2870578
正如上面显示的不到6秒就能插入100万条记录