postgres 使用存储过程批量插入数据
Posted xfgnongmin
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了postgres 使用存储过程批量插入数据相关的知识,希望对你有一定的参考价值。
參考资料(pl/pgsql 官方文档): http://www.postgresql.org/docs/9.3/static/plpgsql.html
create or replace function creatData2() returns
boolean AS
$BODY$
declare ii integer;
begin
II:=1;
FOR ii IN 1..10000000 LOOP
INSERT INTO ipm_model_history_data (res_model, res_id) VALUES (116, ii);
end loop;
return true;
end;
$BODY$
LANGUAGE plpgsql;
select * from creatData2() as tab;
插入1千万条数据耗时610s,当然字段不多的情况下。
以上是关于postgres 使用存储过程批量插入数据的主要内容,如果未能解决你的问题,请参考以下文章