Parallel leader process info in EXPLAIN

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Parallel leader process info in EXPLAIN
Date: 2019-10-23 07:29:38
Message-ID: CA+hUKG+Z22=vkVkXtKRznzRdtj=MtygfZMYUJs8j7ObjzkG1Lw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

While working on some slides explaining EXPLAIN, I couldn't resist the
urge to add the missing $SUBJECT. The attached 0001 patch gives the
following:

Gather ... time=0.146..33.077 rows=1 loops=1)
Workers Planned: 2
Workers Launched: 2
Buffers: shared hit=4425
-> Parallel Seq Scan on public.t ... time=19.421..30.092 rows=0 loops=3)
Filter: (t.i = 42)
Rows Removed by Filter: 333333
Leader: actual time=0.013..32.025 rows=1 loops=1 <--- NEW
Buffers: shared hit=1546 <--- NEW
Worker 0: actual time=29.069..29.069 rows=0 loops=1
Buffers: shared hit=1126
Worker 1: actual time=29.181..29.181 rows=0 loops=1
Buffers: shared hit=1753

Without that, you have to deduce what work was done in the leader, but
I'd rather just show it.

The 0002 patch adjusts Sort for consistency with that scheme, so you get:

Sort ... time=84.303..122.238 rows=333333 loops=3)
Output: t1.i
Sort Key: t1.i
Leader: Sort Method: external merge Disk: 5864kB <--- DIFFERENT
Worker 0: Sort Method: external merge Disk: 3376kB
Worker 1: Sort Method: external merge Disk: 4504kB
Leader: actual time=119.624..165.949 rows=426914 loops=1
Worker 0: actual time=61.239..90.984 rows=245612 loops=1
Worker 1: actual time=72.046..109.782 rows=327474 loops=1

Without the "Leader" label, it's not really clear to the uninitiated
whether you're looking at combined, average or single process numbers.

Of course there are some more things that could be reported in a
similar way eventually, such as filter counters and hash join details.

For the XML/JSON/YAML formats, I decided to use a <Worker> element
with <Worker-Number>-1</Worker-Number> to indicate the leader.
Perhaps there should be a <Leader> element instead?

Thoughts?

Attachment Content-Type Size
0001-Show-parallel-leader-stats-in-EXPLAIN-output.patch application/octet-stream 18.2 KB
0002-Improve-EXPLAIN-of-Sort-in-parallel-queries.patch application/octet-stream 6.4 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2019-10-23 09:13:09 Re: PATCH: logical_work_mem and logical streaming of large in-progress transactions
Previous Message Amit Kapila 2019-10-23 07:29:27 Re: dropdb --force