这些Postgres子查询子选择InitPlans是否并行运行?

我正试图了解Postgres的工作方式。阅读此内容后,https://www.postgresql.org/message-id/4572.1280671706%40sss.pgh.pa.us这些子查询是子选择,因为它们在外部查询中未引用任何内容,对吗?因此,如果它们是独立的,是否意味着它们自然就可以并行/并行运行?

我当时想这些可以与worker并行运行,但是听起来只有一个单独的查询可以并行运行?像这样,它会破坏并行扫描程序的顺序扫描还是索引扫描?

nested Loop Left Join  (cost=20.40..28.41 rows=1 width=2547) (actual time=0.086..0.087 rows=1 loops=1)
  Join Filter: (load_profiles.project_id = projects.id)
  InitPlan 1 (returns $0)
    ->  Index Scan using index_designs_on_project_id_and_tenant_id on designs  (cost=0.11..4.12 rows=1 width=16) (actual time=0.010..0.013 rows=2 loops=1)
          Index Cond: ((project_id = '10821ae7-2867-46b5-a3ac-6b4cb709f7c0'::uuid) AND (tenant_id = '5189ea23-726f-4115-991d-959d09e3b858'::uuid))
  InitPlan 2 (returns $1)
    ->  Index Scan using index_design_requests_on_project_id_and_tenant_id on design_requests  (cost=0.08..4.09 rows=1 width=16) (actual time=0.006..0.006 rows=0 loops=1)
          Index Cond: ((project_id = '10821ae7-2867-46b5-a3ac-6b4cb709f7c0'::uuid) AND (tenant_id = '5189ea23-726f-4115-991d-959d09e3b858'::uuid))
  InitPlan 3 (returns $2)
    ->  Index Scan using index_ortho_images_on_parent_type_and_parent_id on ortho_images  (cost=0.11..7.90 rows=1 width=16) (actual time=0.013..0.015 rows=2 loops=1)
          Index Cond: (((parent_type)::text = 'Project'::text) AND (parent_id = '10821ae7-2867-46b5-a3ac-6b4cb709f7c0'::uuid))
          Filter: (tenant_id = '5189ea23-726f-4115-991d-959d09e3b858'::uuid)
  InitPlan 4 (returns $3)
    ->  Index Scan using index_elevation_sources_on_parent_type_and_parent_id on elevation_sources  (cost=0.08..4.09 rows=1 width=16) (actual time=0.010..0.010 rows=1 loops=1)
          Index Cond: (((parent_type)::text = 'Project'::text) AND (parent_id = '10821ae7-2867-46b5-a3ac-6b4cb709f7c0'::uuid))
          Filter: (tenant_id = '5189ea23-726f-4115-991d-959d09e3b858'::uuid)
  ->  Index Scan using installations_pkey on projects  (cost=0.09..4.09 rows=1 width=2403) (actual time=0.020..0.021 rows=1 loops=1)
        Index Cond: (id = '10821ae7-2867-46b5-a3ac-6b4cb709f7c0'::uuid)
        Filter: (tenant_id = '5189ea23-726f-4115-991d-959d09e3b858'::uuid)
  ->  Index Scan using index_load_profiles_on_project_id_and_tenant_id on load_profiles  (cost=0.11..4.12 rows=1 width=32) (actual time=0.011..0.011 rows=1 loops=1)
        Index Cond: (project_id = '10821ae7-2867-46b5-a3ac-6b4cb709f7c0'::uuid)
Planning time: 0.576 ms
Execution time: 0.167 ms
iCMS 回答:这些Postgres子查询子选择InitPlans是否并行运行?

只有在计划中某处有一个Gather节点(该计划从并行工作程序收集结果)时,执行计划才使用并行查询。因此,这些节点将并行执行。

PostgreSQL中尚不支持并行化这些任务,而且确实不可能,因为所有并行工作人员可能都需要这些结果。

本文链接:https://www.f2er.com/2263609.html

大家都在问