首页 > 其他 > 详细

postgres 水平分表

时间:2020-07-17 22:30:22      阅读:50      评论:0      收藏:0      [点我收藏+]

https://blog.csdn.net/zpf336/article/details/73809481?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-4.nonecase&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-4.nonecase

测试了下,速度确实快了很多:
修正下原文的插入语句:


DO $$
DECLARE
i INTEGER := 1;
identityId BIGINT := 200000000001;
BEGIN
  WHILE i < 50 LOOP
    identityId = identityId + 1;
  raise notice ‘%‘,i;
      -- INSERT 语句
      -- 将字符串转为 uuid cast (‘057b8c51-f62f-4260-bdbb-‘ || identityId as uuid)
	  --begin
	  INSERT INTO almart_all
select
	(select
		array_agg(j::date)
	 from generate_series(‘2015-12-10‘::date, ‘2015-12-14‘::date, ‘1 day‘::interval) as t(j)
	)[floor(random()*4)+1] as date_key,
	floor(random()*24) as hour_key,
	floor(random()*1000000)+1 as client_key,
	floor(random()*100000)+1 as item_key,
	floor(random()*20)+1 as account,
	floor(random()*10000)+1 as expense
from
	generate_series(1,50000,1)
commit;
							 
    i = i + 1;
  END LOOP;
END $$;
  1. 可能是以为我电脑的内存太小(2G),数据插入的速度真是堪忧

postgres 水平分表

原文:https://www.cnblogs.com/qianxunman/p/13332368.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!