我想将十亿行浮动数据插入到postgresql数据库中,以便我可以测试各种postgis函数的性能。我下面的工作花费了很长时间,而且似乎效率很低,而且内存消耗似乎在膨胀。任何人都可以建议一种更好的方法来做到这一点 - 我认为每次插入插入一百万行会更好,但我无法弄清楚如何构建对象,例如:(a, b), (c, d)插入。
非常感谢任何帮助。请注意,我对 SQL 有点新手,所以我无法消化需要高级计算机科学学位才能吸收的超优化解决方案:)我正在寻找“足够好”。
塔,
安德鲁
do $$
declare
position float := 0;
measurement float := 0;
counting integer := 0;
begin
while position < 100 loop
INSERT into lat_longs values (counting, postition);
position := position + 0.0000001;
counting := counting + 1;
end loop;
raise notice 'count: %', counting;
end$$;
Run Code Online (Sandbox Code Playgroud)