PostgreSQL:有没有一种方法可以将我的数据逐段插入空表中以减少加载时间?

我有一个非常简单的查询,如下所示。

drop table if exists table1;
create table table1
  select
    account,campaign_id,customer_id,type,min(date) as date_min
  from table2
  where account in ('1','2') and campaign_id not in ('1','2','3')
  group by account,type;

但是,每次运行此命令时,都会收到此错误消息,提示“ java.io.IOException:连接被远程主机关闭”。我相信是因为数据太大。

有人建议我循环“插入”语句,并在空表中逐段添加数据。

所以我试图逐年添加数据。以下代码仅使用一年。我需要插入多次。

insert into loop_dk (account,date_min)
select account,min(date) as date_min
from dk
where account in ('1','2')
  and campaign_id not in ('1','3') and date between '2016-11-29' and '2017-11-29'
group by account,type;

有人可以告诉我“插入”语句是否是好方法,或者建议我采取任何其他可防止上述错误消息的解决方案?

非常感谢您的帮助!

zys2229888 回答:PostgreSQL:有没有一种方法可以将我的数据逐段插入空表中以减少加载时间?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3150787.html

大家都在问