七叶笔记 » 数据库 » postgresql insert into select无法使用并行查询的解决

postgresql insert into select无法使用并行查询的解决

可以看到走了两个Workers。

下边看一下insert into select:

可以看到并没有Workers的指示,没有启用并行查询。

即使开启强制并行,也无法走并行查询。

原因在官方文档有写:

The query writes any data or locks any database rows. If a query contains a data-modifying operation either at the top level or within a CTE, no parallel plans for that query will be generated. As an exception, the commands CREATE TABLE … AS, SELECT INTO, and CREATE MATERIALIZED VIEW which create a new table and populate it can use a parallel plan.

解决方案有如下三种:

1.select into

2.create table as

3.或者通过导入导出的方式,例如:

一些场景下也会比非并行快。

到此这篇关于postgresql insert into select无法使用并行查询的解决的文章就介绍到这了,更多相关postgresql insert into select并行查询内容请搜索七叶笔记以前的文章或继续浏览下面的相关文章希望大家以后多多支持七叶笔记!

相关文章