-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathparallel.out
More file actions
107 lines (98 loc) · 4.48 KB
/
Copy pathparallel.out
File metadata and controls
107 lines (98 loc) · 4.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
begin;
-- encourage use of parallel plans
set local parallel_setup_cost=0;
set local parallel_tuple_cost=0;
set local min_parallel_table_scan_size=0;
set local max_parallel_workers_per_gather=2;
-- Trace parallel queries
/*dddbs='postgres.db',traceparent='00-00000000000000000000000000000001-0000000000000001-01'*/ select 1 from pg_class limit 1;
?column?
----------
1
(1 row)
/*dddbs='postgres.db',traceparent='00-00000000000000000000000000000001-0000000000000002-01'*/ select 2 from pg_class limit 1;
?column?
----------
2
(1 row)
/*dddbs='postgres.db',traceparent='00-00000000000000000000000000000001-0000000000000003-00'*/ select 3 from pg_class limit 1;
?column?
----------
3
(1 row)
-- Try with parallel tracing disabled
set local pg_tracing.trace_parallel_workers = false;
/*dddbs='postgres.db',traceparent='00-00000000000000000000000000000001-0000000000000004-01'*/ select 4 from pg_class limit 1;
?column?
----------
4
(1 row)
commit;
-- get tx block
select span_id as tx_block_id from pg_tracing_peek_spans where span_type='TransactionBlock' and trace_id='00000000000000000000000000000001' and parent_id='0000000000000001' \gset
-- get root top span id
select span_id as root_span_id from pg_tracing_peek_spans where span_type='Select query' and trace_id='00000000000000000000000000000001' and parent_id=:'tx_block_id' limit 1 \gset
-- Get executor top span id
SELECT span_id as executor_span_id from pg_tracing_peek_spans where span_operation='ExecutorRun' and trace_id='00000000000000000000000000000001' and parent_id=:'root_span_id' \gset
-- Get Limit span id
SELECT span_id as limit_span_id from pg_tracing_peek_spans where span_operation='Limit' and trace_id='00000000000000000000000000000001' and parent_id=:'executor_span_id' \gset
-- Get Gather span id
SELECT span_id as gather_span_id from pg_tracing_peek_spans where span_operation='Gather' and trace_id='00000000000000000000000000000001' and parent_id=:'limit_span_id' \gset
-- Check the select spans that are attached to the root top span
SELECT trace_id, span_type, span_operation from pg_tracing_peek_spans where span_type='Select query' and parent_id=:'gather_span_id' order by span_operation;
trace_id | span_type | span_operation
----------------------------------+--------------+----------------
00000000000000000000000000000001 | Select query | Worker 0
00000000000000000000000000000001 | Select query | Worker 1
(2 rows)
-- Check generated trace_id
SELECT trace_id from pg_tracing_peek_spans group by trace_id;
trace_id
----------------------------------
00000000000000000000000000000001
(1 row)
-- Check number of executor spans
SELECT count(*) from pg_tracing_consume_spans where span_operation='ExecutorRun';
count
-------
7
(1 row)
CALL clean_spans();
-- Test leaderless parallel query
set parallel_setup_cost=0;
set parallel_tuple_cost=0;
set min_parallel_table_scan_size=0;
set max_parallel_workers_per_gather=2;
-- Test a sampled parallel hash join. Parallel Hash nodes may have
-- instrumentation even when their child was executed by another worker.
set enable_nestloop=false;
set enable_mergejoin=false;
/*dddbs='postgres.db',traceparent='00-00000000000000000000000000000001-0000000000000005-01'*/ select count(*) from pg_tracing_test r join pg_tracing_test s using (a) \gset
\echo :count
10000
CALL clean_spans();
-- Test leaderless parallel query
set parallel_leader_participation=false;
/*dddbs='postgres.db',traceparent='00-00000000000000000000000000000001-0000000000000001-01'*/ select 1 from pg_class limit 1;
?column?
----------
1
(1 row)
SELECT span_type, span_operation, lvl FROM peek_ordered_spans where trace_id='00000000000000000000000000000001' ORDER BY lvl, span_operation;
span_type | span_operation | lvl
--------------+----------------------------------+-----
Select query | select $1 from pg_class limit $2 | 0
ExecutorRun | ExecutorRun | 1
Planner | Planner | 1
Limit | Limit | 2
Gather | Gather | 3
Select query | Worker 0 | 4
Select query | Worker 1 | 4
ExecutorRun | ExecutorRun | 5
ExecutorRun | ExecutorRun | 5
SeqScan | SeqScan on pg_class | 6
SeqScan | SeqScan on pg_class | 6
(11 rows)
-- Cleanup
CALL clean_spans();
CALL reset_settings();