飞腾2000+单表插入性能测试
CREATE TABLE t_data_metric_20200316
(
c_inst_id INT NOT NULL ,
c_sub_inst_id INT NOT NULL ,
c_task_time INT NOT NULL ,
c_insert_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
c_metric_id VARCHAR(36) NOT NULL ,
c_data_value DECIMAL(20,2) DEFAULT NULL ,
c_metric_status VARCHAR(20) DEFAULT NULL ,
c_error_msg VARCHAR(50) DEFAULT NULL ,
c_data_value_adjust decimal(20,2) DEFAULT NULL ,
c_data_value_expect decimal(20,2) DEFAULT NULL
);
create index idx_backup_data_metric on t_data_metric_20200316(c_inst_id,c_sub_inst_id,c_task_time,c_metric_id);
CREATE INDEX idx_data_metric_sub ON t_data_metric_20200316 (c_sub_inst_id,c_metric_id,c_task_time);
CREATE INDEX idx_data_metric_time ON t_data_metric_20200316 (c_task_time);
declare
begin
for i in 1..20000000 loop
INSERT INTO T_DATA_METRIC_20200316
(C_INST_ID, C_SUB_INST_ID, C_TASK_TIME, C_INSERT_TIME, C_METRIC_ID, C_DATA_VALUE, C_METRIC_STATUS, C_ERROR_MSG, C_DATA_VALUE_ADJUST, C_DATA_VALUE_EXPECT)
VALUES(1000+i, 1000+i,1584323799+i , CURRENT_TIMESTAMP, 'test001', 9999.99, 'GREEN', 'test_err', 0, 0);
if mod(i,2000)=0 then
commit;
end if;
end loop;
end;
总共1个语句正依次执行...
[执行语句1]:
declare
begin
for i in 1..20000000 loop
INSERT INTO T_DATA_METRIC_20200316
(C_INST_ID, C_SUB_INST_ID, C_TASK_TIME, C_INSERT_TIME, C_METRIC_ID, C_DATA_VALUE, C_METRIC_STATUS, C_ERROR_MSG, C_DATA_VALUE_ADJUST, C_DATA_VALUE_EXPECT)
VALUES(1000+i, 1000+i,1584323799+i , CURRENT_TIMESTAMP, 'test001', 9999.99, 'GREEN', 'test_err', 0, 0);
if mod(i,2000)=0 then
commit;
end if;
end loop;
end;
执行成功, 执行耗时18分 48秒 519毫秒. 执行号:45
影响了1条记录
1条语句执行成功
总共1个语句正依次执行...
[执行语句1]:
declare
begin
for i in 1..2000000 loop
INSERT INTO T_DATA_METRIC_20200316
(C_INST_ID, C_SUB_INST_ID, C_TASK_TIME, C_INSERT_TIME, C_METRIC_ID, C_DATA_VALUE, C_METRIC_STATUS, C_ERROR_MSG, C_DATA_VALUE_ADJUST, C_DATA_VALUE_EXPECT)
VALUES(1000+i, 1000+i,1584323799+i , CURRENT_TIMESTAMP, 'test001', 9999.99, 'GREEN', 'test_err', 0, 0);
if mod(i,2000)=0 then
commit;
end if;
end loop;
end;
执行成功, 执行耗时1分 26秒 24毫秒. 执行号:11
影响了1条记录
1条语句执行成功