Postgresql 脚本与外部服务器的性能缓慢
作为一名前 SQL Server 开发人员,我很好奇,为什么这种脚本在 Postgresql 中会非常慢?
我在公共模式中的本地数据库上有一些表,并且我使用 postgres-fdw 配置了外部服务器,并且外部表在本地链接模式中映射,脚本如下所示:
INSERT INTO linked.table_1 (column_1, column_2) SELECT column_1, column_2 FROM public.table_1;
INSERT INTO linked.table_2 (column_1, column_2) SELECT column_1, column_2 FROM public.table_2;
INSERT INTO linked.table_3 (column_1, column_2) SELECT column_1, column_2 FROM public.table_3;
-- more tables like this...
INSERT INTO linked.table_50 (column_1, column_2) SELECT column_1, column_2 FROM public.table_50;
表很小(数十、数百或数千条记录),所以应该很快,但需要很长时间。为什么?
As a former SQL Server developer, I am curious, why that kind of script can be extremely slow in Postgresql?
I have some tables on local database in public schema, and I configured a foreign server with postgres-fdw, and foreign tables are mapped in linked schema locally, and the script looks like below:
INSERT INTO linked.table_1 (column_1, column_2) SELECT column_1, column_2 FROM public.table_1;
INSERT INTO linked.table_2 (column_1, column_2) SELECT column_1, column_2 FROM public.table_2;
INSERT INTO linked.table_3 (column_1, column_2) SELECT column_1, column_2 FROM public.table_3;
-- more tables like this...
INSERT INTO linked.table_50 (column_1, column_2) SELECT column_1, column_2 FROM public.table_50;
Tables are small (tens, hundreds or thousands of records), so it should be pretty fast, but it takes long minutes. Why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论