Hi folks - I'm having trouble understanding what some of the stats mean in the execution plan output when parallel workers are used. I've tried to read up about it, but I haven't been able to find anything that explains what I'm seeing. Apologies in advance if there's documentation I've been too stupid to find. I've run the following query. The "towns" table is a massive
table that I created in order to get some big numbers on a
parallel query - don't worry, this isn't a real query I want to
make faster, just a silly example I'd like to understand. EXPLAIN (ANALYZE, FORMAT JSON, BUFFERS, VERBOSE) SELECT name, code, article FROM towns ORDER BY name ASC, code DESC; The output looks like this: [ { "Plan": { "Node Type": "Gather Merge", "Parallel Aware": false, "Startup Cost": 1013948.54, "Total Cost": 1986244.55, "Plan Rows": 8333384, "Plan Width": 77, "Actual Startup Time": 42978.838, "Actual Total Time": 60628.982, "Actual Rows": 10000010, "Actual Loops": 1, "Output": ["name", "code", "article"], "Workers Planned": 2, "Workers Launched": 2, "Shared Hit Blocks": 29, "Shared Read Blocks": 47641, "Shared Dirtied Blocks": 0, "Shared Written Blocks": 0, "Local Hit Blocks": 0, "Local Read Blocks": 0, "Local Dirtied Blocks": 0, "Local Written Blocks": 0, "Temp Read Blocks": 91342, "Temp Written Blocks": 91479, "Plans": [ { "Node Type": "Sort", "Parent Relationship": "Outer", "Parallel Aware": false, "Startup Cost": 1012948.52, "Total Cost": 1023365.25, "Plan Rows": 4166692, "Plan Width": 77, "Actual Startup Time": 42765.496, "Actual Total Time": 48526.168, "Actual Rows": 3333337, "Actual Loops": 3, "Output": ["name", "code", "article"], "Sort Key": ["towns.name", "towns.code DESC"], "Sort Method": "external merge", "Sort Space Used": 283856, "Sort Space Type": "Disk", "Shared Hit Blocks": 170, "Shared Read Blocks": 142762, "Shared Dirtied Blocks": 0, "Shared Written Blocks": 0, "Local Hit Blocks": 0, "Local Read Blocks": 0, "Local Dirtied Blocks": 0, "Local Written Blocks": 0, "Temp Read Blocks": 273289, "Temp Written Blocks": 273700, "Workers": [ { "Worker Number": 0, "Actual Startup Time": 42588.662, "Actual Total Time": 48456.662, "Actual Rows": 3277980, "Actual Loops": 1, "Shared Hit Blocks": 72, "Shared Read Blocks": 46794, "Shared Dirtied Blocks": 0, "Shared Written Blocks": 0, "Local Hit Blocks": 0, "Local Read Blocks": 0, "Local Dirtied Blocks": 0, "Local Written Blocks": 0, "Temp Read Blocks": 89067, "Temp Written Blocks": 89202 }, { "Worker Number": 1, "Actual Startup Time": 42946.705, "Actual Total Time": 48799.414, "Actual Rows": 3385130, "Actual Loops": 1, "Shared Hit Blocks": 69, "Shared Read Blocks": 48327, "Shared Dirtied Blocks": 0, "Shared Written Blocks": 0, "Local Hit Blocks": 0, "Local Read Blocks": 0, "Local Dirtied Blocks": 0, "Local Written Blocks": 0, "Temp Read Blocks": 92880, "Temp Written Blocks": 93019 } ], "Plans": [ { "Node Type": "Seq Scan", "Parent Relationship": "Outer", "Parallel Aware": true, "Relation Name": "towns", "Schema": "public", "Alias": "towns", "Startup Cost": 0.00, "Total Cost": 184524.92, "Plan Rows": 4166692, "Plan Width": 77, "Actual Startup Time": 0.322, "Actual Total Time": 8305.886, "Actual Rows": 3333337, "Actual Loops": 3, "Output": ["name", "code", "article"], "Shared Hit Blocks": 96, "Shared Read Blocks": 142762, "Shared Dirtied Blocks": 0, "Shared Written Blocks": 0, "Local Hit Blocks": 0, "Local Read Blocks": 0, "Local Dirtied Blocks": 0, "Local Written Blocks": 0, "Temp Read Blocks": 0, "Temp Written Blocks": 0, "Workers": [ { "Worker Number": 0, "Actual Startup Time": 0.105, "Actual Total Time": 8394.629, "Actual Rows": 3277980, "Actual Loops": 1, "Shared Hit Blocks": 35, "Shared Read Blocks": 46794, "Shared Dirtied Blocks": 0, "Shared Written Blocks": 0, "Local Hit Blocks": 0, "Local Read Blocks": 0, "Local Dirtied Blocks": 0, "Local Written Blocks": 0, "Temp Read Blocks": 0, "Temp Written Blocks": 0 }, { "Worker Number": 1, "Actual Startup Time": 0.113, "Actual Total Time": 8139.382, "Actual Rows": 3385130, "Actual Loops": 1, "Shared Hit Blocks": 32, "Shared Read Blocks": 48327, "Shared Dirtied Blocks": 0, "Shared Written Blocks": 0, "Local Hit Blocks": 0, "Local Read Blocks": 0, "Local Dirtied Blocks": 0, "Local Written Blocks": 0, "Temp Read Blocks": 0, "Temp Written Blocks": 0 } ] } ] } ] }, "Planning Time": 22.898, "Triggers": [ ], "Execution Time": 61133.161 } ] Or a more slimmed-down version, with just the confusing fields: [ { "Plan": { "Node Type": "Gather Merge", "Parallel Aware": false, "Actual Total Time": 60628.982, "Actual Rows": 10000010, "Actual Loops": 1, "Workers Planned": 2, "Workers Launched": 2, "Plans": [ { "Node Type": "Sort", "Parent Relationship": "Outer", "Parallel Aware": false, "Actual Total Time": 48526.168, "Actual Rows": 3333337, "Actual Loops": 3, "Workers": [ { "Worker Number": 0, "Actual Total Time": 48456.662, "Actual Rows": 3277980, "Actual Loops": 1 }, { "Worker Number": 1, "Actual Total Time": 48799.414, "Actual Rows": 3385130, "Actual Loops": 1 } ], "Plans": [ { "Node Type": "Seq Scan", "Parallel Aware": true, "Actual Total Time": 8305.886, "Actual Rows": 3333337, "Actual Loops": 3, "Workers": [ { "Worker Number": 0, "Actual Total Time": 8394.629, "Actual Rows": 3277980, "Actual Loops": 1 }, { "Worker Number": 1, "Actual Total Time": 8139.382, "Actual Rows": 3385130, "Actual Loops": 1 } ] } ] } ] }, "Execution Time": 61133.161 } ] The things I'm struggling to understand are:
Other info about my setup:
Thanks in advance, I'm sure I've done something silly or misunderstood something obvious but I can't work out what it is for the life of me. Dave |