Re: Parallel Seq Scan - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: Parallel Seq Scan
Date
Msg-id CAFj8pRBF-i=qDg9b5nZrXYfChzBEZWmthxYPhidQvwoMOjHtzg@mail.gmail.com
Whole thread Raw
In response to Re: Parallel Seq Scan  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: Parallel Seq Scan  (Thom Brown <thom@linux.com>)
Re: Parallel Seq Scan  (Robert Haas <robertmhaas@gmail.com>)
Re: Parallel Seq Scan  (Amit Kapila <amit.kapila16@gmail.com>)
List pgsql-hackers
Hi

I have a first query

I looked on EXPLAIN ANALYZE output and the numbers of filtered rows are differen

postgres=# set max_parallel_degree to 4;
SET
Time: 0.717 ms
postgres=# EXPLAIN ANALYZE select count(*) from xxx where a % 10 = 0;
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                          QUERY PLAN                                                           │
╞═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╡
│ Aggregate  (cost=9282.50..9282.51 rows=1 width=0) (actual time=142.541..142.541 rows=1 loops=1)                               │
│   ->  Gather  (cost=1000.00..9270.00 rows=5000 width=0) (actual time=0.633..130.926 rows=100000 loops=1)                      │
│         Number of Workers: 2                                                                                                  │
│         ->  Parallel Seq Scan on xxx  (cost=0.00..7770.00 rows=5000 width=0) (actual time=0.052..411.303 rows=169631 loops=1) │
│               Filter: ((a % 10) = 0)                                                                                          │
│               Rows Removed by Filter: 1526399                                                                                 │
│ Planning time: 0.167 ms                                                                                                       │
│ Execution time: 144.519 ms                                                                                                    │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
(8 rows)

Time: 145.374 ms
postgres=# set max_parallel_degree to 1;
SET
Time: 0.706 ms
postgres=# EXPLAIN ANALYZE select count(*) from xxx where a % 10 = 0;
┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                           QUERY PLAN                                                           │
╞════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╡
│ Aggregate  (cost=14462.50..14462.51 rows=1 width=0) (actual time=163.355..163.355 rows=1 loops=1)                              │
│   ->  Gather  (cost=1000.00..14450.00 rows=5000 width=0) (actual time=0.485..152.827 rows=100000 loops=1)                      │
│         Number of Workers: 1                                                                                                   │
│         ->  Parallel Seq Scan on xxx  (cost=0.00..12950.00 rows=5000 width=0) (actual time=0.043..309.740 rows=145364 loops=1) │
│               Filter: ((a % 10) = 0)                                                                                           │
│               Rows Removed by Filter: 1308394                                                                                  │
│ Planning time: 0.129 ms                                                                                                        │
│ Execution time: 165.102 ms                                                                                                     │
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
(8 rows)


Rows removed by filter: 1308394 X 1526399. Is it expected?

pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Foreign join pushdown vs EvalPlanQual
Next
From: Thom Brown
Date:
Subject: Re: Parallel Seq Scan