<div dir="ltr"><div class="gmail_default" style="font-size:small">Hi Tatsuo,</div><div class="gmail_default" style="font-size:small">actually this behaviour was reported to me by developers and I blindly trusted their analysis, so I asked them how to reproduce the problem.<br></div><div class="gmail_default" style="font-size:small">In the meantime I performed the same exact test with the EXPLAIN and came to the same conclusion :-)</div><div class="gmail_default" style="font-size:small">I'll keep you posted.</div><div class="gmail_default" style="font-size:small">Thanks a lot</div><div class="gmail_default" style="font-size:small">Regards</div><div class="gmail_default" style="font-size:small">Luca</div><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Oct 25, 2021 at 11:53 AM Tatsuo Ishii <<a href="mailto:ishii@sraoss.co.jp">ishii@sraoss.co.jp</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">> Hi all,<br>
> we noticed that if we run a select count(*) from a huge table connecting to<br>
> pgpool, postgres will start only 1 worker, while if we start the same query<br>
> with a direct connection to the DB postgres will start 5 workers, so<br>
> obviously execution time will be 5x time slower via pgpool.<br>
> PGpool should pass the statement to postgres so the execution on the<br>
> backend should be the same.<br>
> <br>
> I'm missing the reason for this behaviour, can anyone explain?<br>
> <br>
> Current versions of the components are PostgreSQL 12.8 and PGPool-II 4.2.3.<br>
<br>
That's really strang and of course I was not able to reproduce it.<br>
<br>
[directly connect to PostgreSQL]<br>
<br>
t-ishii$ psql -p 11002 test<br>
psql (14.0)<br>
Type "help" for help.<br>
<br>
test=# explain analyze select count(*) from pgbench_accounts;<br>
                                                                                      QUERY PLAN                                                                                       <br>
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<br>
 Finalize Aggregate  (cost=22188.97..22188.98 rows=1 width=8) (actual time=74.360..77.116 rows=1 loops=1)<br>
   ->  Gather  (cost=22188.76..22188.97 rows=2 width=8) (actual time=74.301..77.108 rows=3 loops=1)<br>
         Workers Planned: 2<br>
         Workers Launched: 2<br>
         ->  Partial Aggregate  (cost=21188.76..21188.77 rows=1 width=8) (actual time=72.055..72.056 rows=1 loops=3)<br>
               ->  Parallel Index Only Scan using pgbench_accounts_pkey on pgbench_accounts  (cost=0.42..20147.09 rows=416667 width=0) (actual time=0.038..49.776 rows=333333 loops=3)<br>
                     Heap Fetches: 0<br>
 Planning Time: 0.288 ms<br>
 Execution Time: 77.182 ms<br>
(9 rows)<br>
<br>
[via Pgpool-II]<br>
<br>
t-ishii$ psql -p 11000 test<br>
psql (14.0)<br>
Type "help" for help.<br>
<br>
test=# explain analyze select count(*) from pgbench_accounts;<br>
                                                                                      QUERY PLAN                                                                                       <br>
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<br>
 Finalize Aggregate  (cost=22188.97..22188.98 rows=1 width=8) (actual time=82.885..84.496 rows=1 loops=1)<br>
   ->  Gather  (cost=22188.76..22188.97 rows=2 width=8) (actual time=82.829..84.487 rows=3 loops=1)<br>
         Workers Planned: 2<br>
         Workers Launched: 2<br>
         ->  Partial Aggregate  (cost=21188.76..21188.77 rows=1 width=8) (actual time=80.456..80.457 rows=1 loops=3)<br>
               ->  Parallel Index Only Scan using pgbench_accounts_pkey on pgbench_accounts  (cost=0.42..20147.09 rows=416667 width=0) (actual time=0.053..58.590 rows=333333 loops=3)<br>
                     Heap Fetches: 0<br>
 Planning Time: 0.346 ms<br>
 Execution Time: 84.571 ms<br>
(9 rows)<br>
<br>
How do you issue the query exactly?<br>
--<br>
Tatsuo Ishii<br>
SRA OSS, Inc. Japan<br>
English: <a href="http://www.sraoss.co.jp/index_en.php" rel="noreferrer" target="_blank">http://www.sraoss.co.jp/index_en.php</a><br>
Japanese:<a href="http://www.sraoss.co.jp" rel="noreferrer" target="_blank">http://www.sraoss.co.jp</a><br>
</blockquote></div>