| From: | Frédéric Yhuel <frederic(dot)yhuel(at)dalibo(dot)com> | 
|---|---|
| To: | Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Richard Guo <guofenglinux(at)gmail(dot)com> | 
| Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org | 
| Subject: | Re: Allowing parallel-safe initplans | 
| Date: | 2024-10-02 11:58:45 | 
| Message-ID: | 80380d0e-f8cd-4d70-b14f-f11ddd8b7ef5@dalibo.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-hackers | 
Le 12/04/2023 à 20:06, Robert Haas a écrit :
>> There's only one existing test case that visibly changes plan with
>> these changes.  The new plan is clearly saner-looking than before,
>> and testing with some data loaded into the table confirms that it
>> is faster.  I'm not sure if it's worth devising more test cases.
> It seems like it would be nice to see one or two additional scenarios
> where these changes bring a benefit, with different kinds of plan
> shapes.
Hi,
Currently working on illustrating some points in the v17 release notes, 
I'm trying to come up with a sexier scenario than the test case, but it 
seems that with a non-trivial InitPlan (2nd explain below), we still 
have a non-parallel Append node at the top:
SET parallel_setup_cost = 0;
SET parallel_tuple_cost = 0;
SET min_parallel_table_scan_size = 10;
CREATE TABLE foo (a int) PARTITION by LIST(a);
CREATE TABLE foo_0 PARTITION OF foo FOR VALUES IN (0);
CREATE TABLE foo_1 PARTITION OF foo FOR VALUES IN (1);
EXPLAIN (COSTS OFF)
	SELECT * FROM foo WHERE a = (SELECT 2)
	UNION ALL
	SELECT * FROM foo WHERE a = 0;
                      QUERY PLAN
-----------------------------------------------------
  Gather
    Workers Planned: 2
    ->  Parallel Append
          ->  Parallel Append
                InitPlan 1
                  ->  Result
                ->  Parallel Seq Scan on foo_0 foo_1
                      Filter: (a = (InitPlan 1).col1)
                ->  Parallel Seq Scan on foo_1 foo_2
                      Filter: (a = (InitPlan 1).col1)
          ->  Parallel Seq Scan on foo_0 foo_3
                Filter: (a = 0)
EXPLAIN (COSTS OFF)
	SELECT * FROM foo WHERE a = (SELECT max(a) FROM foo)
	UNION ALL
	SELECT * FROM foo WHERE a = 0;
                                QUERY PLAN
------------------------------------------------------------------------
  Append
    ->  Gather
          Workers Planned: 2
          InitPlan 1
            ->  Finalize Aggregate
                  ->  Gather
                        Workers Planned: 2
                        ->  Partial Aggregate
                              ->  Parallel Append
                                    ->  Parallel Seq Scan on foo_0 foo_5
                                    ->  Parallel Seq Scan on foo_1 foo_6
          ->  Parallel Append
                ->  Parallel Seq Scan on foo_0 foo_1
                      Filter: (a = (InitPlan 1).col1)
                ->  Parallel Seq Scan on foo_1 foo_2
                      Filter: (a = (InitPlan 1).col1)
    ->  Gather
          Workers Planned: 1
          ->  Parallel Seq Scan on foo_0 foo_3
                Filter: (a = 0)
Did I miss something?
Best regards,
Frédéric
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Alvaro Herrera | 2024-10-02 12:19:35 | Re: not null constraints, again | 
| Previous Message | Peter Eisentraut | 2024-10-02 11:30:46 | Rename PageData to XLogPageData |