From 6e85d09e19e949b9d8b62150703d5a7aa4457d13 Mon Sep 17 00:00:00 2001
From: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Date: Wed, 28 Oct 2026 06:49:22 +0000
Subject: [PATCH v2 7/8] Report buffer access strategy for table scans in
 EXPLAIN

When ANALYZE and BUFFERS are enabled, report the buffer access strategy
selected by sequential, sample, bitmap heap, TID, and TID range scans.

Read the strategy from leader and per-worker table scan instrumentation and
report it only for processes that execute the scan.

Add documentation and TAP coverage for serial and parallel execution,
never-executed scans, and omission when BUFFERS is disabled.

Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Sami Imseih <samimseih.pg@gmail.com>
Discussion: https://postgr.es/m/auCYYbDyrQEwIsQq@bdtpg
---
 doc/src/sgml/ref/explain.sgml                 |   7 +
 src/backend/commands/explain.c                | 115 +++++++++
 src/test/modules/test_misc/meson.build        |   1 +
 .../t/016_explain_buffer_strategy.pl          | 209 ++++++++++++++++
 src/test/regress/expected/explain.out         | 231 +++++++++---------
 src/test/regress/sql/explain.sql              |   2 +
 6 files changed, 454 insertions(+), 111 deletions(-)
  15.8% src/backend/commands/
  33.6% src/test/modules/test_misc/t/
  47.4% src/test/regress/expected/

diff --git a/doc/src/sgml/ref/explain.sgml b/doc/src/sgml/ref/explain.sgml
index f38d31e106a..f7ae8f1b2bd 100644
--- a/doc/src/sgml/ref/explain.sgml
+++ b/doc/src/sgml/ref/explain.sgml
@@ -200,6 +200,13 @@ ROLLBACK;
       number of blocks <emphasis>written</emphasis> indicates the number of
       previously-dirtied blocks evicted from cache by this backend during
       query processing.
+      When both <literal>ANALYZE</literal> and <literal>BUFFERS</literal> are
+      enabled, executed <literal>Seq Scan</literal>,
+      <literal>Sample Scan</literal>, <literal>Bitmap Heap Scan</literal>,
+      <literal>TID Scan</literal>, and <literal>TID Range Scan</literal> plan
+      nodes report the <glossterm
+      linkend="glossary-buffer-access-strategy">buffer access
+      strategy</glossterm> used by the table scan.
       The number of blocks shown for an
       upper-level node includes those used by all its child nodes.  In text
       format, only non-zero values are printed.  Buffers information is
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
index d0ce72d83ff..c2a30077b4a 100644
--- a/src/backend/commands/explain.c
+++ b/src/backend/commands/explain.c
@@ -140,6 +140,7 @@ static void show_hashagg_info(AggState *aggstate, ExplainState *es);
 static void show_indexscan_info(PlanState *planstate, ExplainState *es);
 static void show_tidbitmap_info(BitmapHeapScanState *planstate,
 								ExplainState *es);
+static void show_scan_buffer_access_strategy(ScanState *planstate, ExplainState *es);
 static void show_scan_io_usage(ScanState *planstate,
 							   ExplainState *es);
 static void show_instrumentation_count(const char *qlabel, int which,
@@ -2010,6 +2011,7 @@ ExplainNode(PlanState *planstate, List *ancestors,
 				show_instrumentation_count("Rows Removed by Filter", 1,
 										   planstate, es);
 			show_tidbitmap_info((BitmapHeapScanState *) planstate, es);
+			show_scan_buffer_access_strategy((ScanState *) planstate, es);
 			show_scan_io_usage((ScanState *) planstate, es);
 			break;
 		case T_SampleScan:
@@ -2029,6 +2031,7 @@ ExplainNode(PlanState *planstate, List *ancestors,
 										   planstate, es);
 			if (IsA(plan, CteScan))
 				show_ctescan_info(castNode(CteScanState, planstate), es);
+			show_scan_buffer_access_strategy((ScanState *) planstate, es);
 			show_scan_io_usage((ScanState *) planstate, es);
 			break;
 		case T_Gather:
@@ -2129,6 +2132,7 @@ ExplainNode(PlanState *planstate, List *ancestors,
 				if (plan->qual)
 					show_instrumentation_count("Rows Removed by Filter", 1,
 											   planstate, es);
+				show_scan_buffer_access_strategy((ScanState *) planstate, es);
 			}
 			break;
 		case T_TidRangeScan:
@@ -2146,6 +2150,7 @@ ExplainNode(PlanState *planstate, List *ancestors,
 				if (plan->qual)
 					show_instrumentation_count("Rows Removed by Filter", 1,
 											   planstate, es);
+				show_scan_buffer_access_strategy((ScanState *) planstate, es);
 				show_scan_io_usage((ScanState *) planstate, es);
 			}
 			break;
@@ -4027,6 +4032,38 @@ show_tidbitmap_info(BitmapHeapScanState *planstate, ExplainState *es)
 	}
 }
 
+/*
+ * Return the name of a buffer access strategy for EXPLAIN.
+ */
+static const char *
+buffer_access_strategy_name(BufferAccessStrategyType strategy)
+{
+	switch (strategy)
+	{
+		case BAS_NORMAL:
+			return "normal";
+		case BAS_BULKREAD:
+			return "bulkread";
+		case BAS_BULKWRITE:
+			return "bulkwrite";
+		case BAS_VACUUM:
+			return "vacuum";
+	}
+
+	elog(ERROR, "unrecognized buffer access strategy type: %d", strategy);
+	pg_unreachable();
+}
+
+/*
+ * Print the buffer access strategy.
+ */
+static void
+print_buffer_access_strategy(ExplainState *es,
+							 BufferAccessStrategyType strategy)
+{
+	ExplainPropertyText("Buffer Access Strategy", buffer_access_strategy_name(strategy), es);
+}
+
 /*
  * Print I/O stats - prefetching and I/O performed
  *
@@ -4111,6 +4148,15 @@ get_table_scan_instrumentation(ScanState *planstate, int worker)
 				SharedBitmapHeapInstrumentation *sinstrument =
 					((BitmapHeapScanState *) planstate)->sinstrument;
 
+				if (sinstrument && worker < sinstrument->num_workers)
+					return &sinstrument->sinstrument[worker].stats;
+				break;
+			}
+		case T_SampleScan:
+			{
+				SharedSampleScanInstrumentation *sinstrument =
+					((SampleScanState *) planstate)->sinstrument;
+
 				if (sinstrument && worker < sinstrument->num_workers)
 					return &sinstrument->sinstrument[worker].stats;
 				break;
@@ -4120,6 +4166,15 @@ get_table_scan_instrumentation(ScanState *planstate, int worker)
 				SharedSeqScanInstrumentation *sinstrument =
 					((SeqScanState *) planstate)->sinstrument;
 
+				if (sinstrument && worker < sinstrument->num_workers)
+					return &sinstrument->sinstrument[worker].stats;
+				break;
+			}
+		case T_TidScan:
+			{
+				SharedTidScanInstrumentation *sinstrument =
+					((TidScanState *) planstate)->tss_sinstrument;
+
 				if (sinstrument && worker < sinstrument->num_workers)
 					return &sinstrument->sinstrument[worker].stats;
 				break;
@@ -4140,6 +4195,66 @@ get_table_scan_instrumentation(ScanState *planstate, int worker)
 	return NULL;
 }
 
+/*
+ * Show the buffer access strategy for a scan node.
+ */
+static void
+show_scan_buffer_access_strategy(ScanState *planstate, ExplainState *es)
+{
+	WorkerNodeInstrumentation *worker_instrument = planstate->ps.worker_instrument;
+	TableScanInstrumentation *instrument;
+	double		leader_nloops = planstate->ps.instrument ?
+		planstate->ps.instrument->nloops : 0;
+
+	if (!es->buffers)
+		return;
+
+	/* Report the buffer access strategy only for these scan types. */
+	switch (nodeTag(planstate->ps.plan))
+	{
+		case T_BitmapHeapScan:
+		case T_SampleScan:
+		case T_SeqScan:
+		case T_TidScan:
+		case T_TidRangeScan:
+			break;
+		default:
+			return;
+	}
+
+	instrument = get_table_scan_instrumentation(planstate, -1);
+
+	if (worker_instrument)
+	{
+		/*
+		 * After parallel cleanup, the node's loop count includes worker
+		 * loops. Remove them to determine whether the leader executed the
+		 * scan.
+		 */
+		for (int i = 0; i < worker_instrument->num_workers; ++i)
+		{
+			double		worker_nloops = worker_instrument->instrument[i].nloops;
+			TableScanInstrumentation *winstrument =
+				get_table_scan_instrumentation(planstate, i);
+
+			leader_nloops -= worker_nloops;
+
+			if (!winstrument || !winstrument->strategy_valid ||
+				worker_nloops <= 0)
+				continue;
+
+			if (es->workers_state)
+				ExplainOpenWorker(i, es);
+			print_buffer_access_strategy(es, winstrument->strategy);
+			if (es->workers_state)
+				ExplainCloseWorker(i, es);
+		}
+	}
+
+	if (instrument && instrument->strategy_valid && leader_nloops > 0)
+		print_buffer_access_strategy(es, instrument->strategy);
+}
+
 /*
  * Show information about prefetch and I/O in a scan node.
  */
diff --git a/src/test/modules/test_misc/meson.build b/src/test/modules/test_misc/meson.build
index 5d81f5b13be..e71754ebbc3 100644
--- a/src/test/modules/test_misc/meson.build
+++ b/src/test/modules/test_misc/meson.build
@@ -24,6 +24,7 @@ tests += {
       't/013_temp_obj_multisession.pl',
       't/014_log_statement_max_length.pl',
       't/015_temp_schema_exit_deferrable.pl',
+      't/016_explain_buffer_strategy.pl',
     ],
     # The injection points are cluster-wide, so disable installcheck
     'runningcheck': false,
diff --git a/src/test/modules/test_misc/t/016_explain_buffer_strategy.pl b/src/test/modules/test_misc/t/016_explain_buffer_strategy.pl
new file mode 100644
index 00000000000..67b995a10e2
--- /dev/null
+++ b/src/test/modules/test_misc/t/016_explain_buffer_strategy.pl
@@ -0,0 +1,209 @@
+# Copyright (c) 2026, PostgreSQL Global Development Group
+
+use strict;
+use warnings FATAL => 'all';
+
+use JSON::PP qw(decode_json);
+use PostgreSQL::Test::Cluster;
+use PostgreSQL::Test::Utils;
+use Test::More;
+
+my $node = PostgreSQL::Test::Cluster->new('main');
+$node->init;
+$node->append_conf(
+	'postgresql.conf', qq{
+shared_buffers = '1MB'
+max_parallel_workers_per_gather = 0
+});
+$node->start;
+
+$node->safe_psql(
+	'postgres', qq{
+CREATE TABLE test_strategy AS
+  SELECT g, repeat('x', 1000) AS payload
+  FROM generate_series(1, 4000) AS g;
+ALTER TABLE test_strategy SET (parallel_workers = 2);
+CREATE INDEX test_strategy_g_idx ON test_strategy (g);
+CREATE TABLE test_normal AS SELECT 1 AS g;
+});
+
+my $seqscan = explain_json('SELECT * FROM test_strategy');
+is($seqscan->{'Node Type'}, 'Seq Scan', 'sequential scan plan');
+check_strategy($seqscan, 'bulkread', 'sequential scan');
+
+my $normal_scan = explain_json('SELECT * FROM test_normal');
+is($normal_scan->{'Node Type'}, 'Seq Scan', 'small sequential scan plan');
+check_strategy($normal_scan, 'normal', 'small sequential scan');
+
+my $never_executed_plan = decode_json(
+	$node->safe_psql(
+		'postgres', qq{
+SET plan_cache_mode = force_generic_plan;
+PREPARE never_execute(bool) AS SELECT * FROM test_normal WHERE \$1;
+EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON)
+  EXECUTE never_execute(false);
+}))->[0]->{'Plan'};
+my $never_executed_scan = find_plan_node($never_executed_plan, 'Seq Scan');
+ok(defined $never_executed_scan,
+	'never-executed plan contains a sequential scan');
+is($never_executed_scan->{'Actual Loops'},
+	0, 'sequential scan was not executed');
+ok( !exists $never_executed_scan->{'Buffer Access Strategy'},
+	'strategy is not shown for a never-executed scan');
+
+# Sample scans use the buffer access strategy without a read stream.
+my $samplescan =
+  explain_json('SELECT * FROM test_strategy TABLESAMPLE SYSTEM (100)');
+is($samplescan->{'Node Type'}, 'Sample Scan', 'sample scan plan');
+check_strategy($samplescan, 'bulkread', 'sample scan');
+
+my $bitmap_plan = decode_json(
+	$node->safe_psql(
+		'postgres', qq{
+SET enable_seqscan = off;
+SET enable_indexscan = off;
+EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON)
+  SELECT * FROM test_strategy WHERE g BETWEEN 1 AND 1000;
+}))->[0]->{'Plan'};
+my $bitmap_scan = find_plan_node($bitmap_plan, 'Bitmap Heap Scan');
+ok(defined $bitmap_scan, 'bitmap heap scan plan');
+check_strategy($bitmap_scan, 'normal', 'bitmap heap scan');
+
+my $tid_plan =
+  explain_json("SELECT * FROM test_strategy WHERE ctid = '(0,1)'");
+my $tid_scan = find_plan_node($tid_plan, 'Tid Scan');
+ok(defined $tid_scan, 'TID scan plan');
+check_strategy($tid_scan, 'normal', 'TID scan');
+
+my $tidrange_plan =
+  explain_json(
+	"SELECT * FROM test_strategy WHERE ctid >= '(0,1)' AND ctid < '(1,1)'");
+my $tidrange_scan = find_plan_node($tidrange_plan, 'Tid Range Scan');
+ok(defined $tidrange_scan, 'TID range scan plan');
+check_strategy($tidrange_scan, 'normal', 'TID range scan');
+
+my $worker_samplescan_plan = decode_json(
+	$node->safe_psql(
+		'postgres', qq{
+SET max_parallel_workers_per_gather = 1;
+SET debug_parallel_query = on;
+EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON)
+  SELECT * FROM test_strategy TABLESAMPLE SYSTEM (100);
+}))->[0]->{'Plan'};
+check_worker_strategy($worker_samplescan_plan, 'Sample Scan', 'bulkread',
+	'worker-only sample scan');
+
+my $worker_tid_plan = decode_json(
+	$node->safe_psql(
+		'postgres', qq{
+SET max_parallel_workers_per_gather = 1;
+SET debug_parallel_query = on;
+EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON)
+  SELECT * FROM test_strategy WHERE ctid = '(0,1)';
+}))->[0]->{'Plan'};
+check_worker_strategy($worker_tid_plan, 'Tid Scan', 'normal',
+	'worker-only TID scan');
+
+my $without_buffers = decode_json(
+	$node->safe_psql(
+		'postgres',
+		'EXPLAIN (ANALYZE, BUFFERS OFF, IO, FORMAT JSON) '
+		  . 'SELECT * FROM test_strategy'))->[0]->{'Plan'};
+ok( !exists $without_buffers->{'Buffer Access Strategy'},
+	'strategy is not shown when BUFFERS is disabled');
+ok( exists $without_buffers->{'Average Prefetch Distance'},
+	'read stream statistics are shown when only IO is enabled');
+
+my $text = $node->safe_psql('postgres',
+		'EXPLAIN (ANALYZE, BUFFERS, COSTS OFF, TIMING OFF, SUMMARY OFF) '
+	  . 'SELECT * FROM test_strategy');
+like(
+	$text,
+	qr/Buffer Access Strategy: bulkread/,
+	'text output reports the strategy');
+
+my $parallel_plan = decode_json(
+	$node->safe_psql(
+		'postgres', qq{
+SET max_parallel_workers_per_gather = 2;
+SET min_parallel_table_scan_size = 0;
+SET parallel_setup_cost = 0;
+SET parallel_tuple_cost = 0;
+SET parallel_leader_participation = off;
+EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON)
+  SELECT count(*) FROM test_strategy;
+}))->[0]->{'Plan'};
+my $gather = find_plan_node($parallel_plan, 'Gather');
+my $parallel_scan = find_plan_node($parallel_plan, 'Seq Scan');
+
+ok(defined $gather, 'parallel plan contains a Gather');
+cmp_ok($gather->{'Workers Launched'}, '>', 0, 'parallel workers launched');
+ok(defined $parallel_scan, 'parallel plan contains a sequential scan');
+ok( !exists $parallel_scan->{'Buffer Access Strategy'},
+	'strategy is not shown for a non-participating leader');
+my $workers = $parallel_scan->{'Workers'};
+ok(ref $workers eq 'ARRAY' && @$workers > 0,
+	'parallel scan reports worker strategy information');
+
+foreach my $worker (@$workers)
+{
+	is($worker->{'Buffer Access Strategy'},
+		'bulkread', 'parallel worker reports the strategy');
+}
+
+$node->stop;
+
+done_testing();
+
+sub explain_json
+{
+	my ($query) = @_;
+	my $output = $node->safe_psql('postgres',
+		"EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON) $query");
+
+	return decode_json($output)->[0]->{'Plan'};
+}
+
+sub check_strategy
+{
+	my ($plan, $strategy, $description) = @_;
+
+	is($plan->{'Buffer Access Strategy'},
+		$strategy, "$description uses the $strategy strategy");
+}
+
+sub check_worker_strategy
+{
+	my ($plan, $type, $strategy, $description) = @_;
+	my $scan = find_plan_node($plan, $type);
+
+	ok(defined $scan, "$description plan contains a $type");
+	ok( !exists $scan->{'Buffer Access Strategy'},
+		"$description does not report a leader strategy");
+
+	my $workers = $scan->{'Workers'};
+
+	ok( ref $workers eq 'ARRAY' && @$workers > 0,
+		"$description reports worker strategy information");
+	foreach my $worker (@$workers)
+	{
+		is($worker->{'Buffer Access Strategy'},
+			$strategy, "$description worker uses the $strategy strategy");
+	}
+}
+
+sub find_plan_node
+{
+	my ($plan, $type) = @_;
+
+	return $plan if $plan->{'Node Type'} eq $type;
+
+	foreach my $child (@{ $plan->{'Plans'} // [] })
+	{
+		my $result = find_plan_node($child, $type);
+
+		return $result if defined $result;
+	}
+
+	return;
+}
diff --git a/src/test/regress/expected/explain.out b/src/test/regress/expected/explain.out
index 74a4d87801e..1b7a94f4e10 100644
--- a/src/test/regress/expected/explain.out
+++ b/src/test/regress/expected/explain.out
@@ -89,9 +89,10 @@ select explain_filter('explain (analyze, buffers, format text) select * from int
                                          explain_filter                                          
 -------------------------------------------------------------------------------------------------
  Seq Scan on int8_tbl i8  (cost=N.N..N.N rows=N width=N) (actual time=N.N..N.N rows=N.N loops=N)
+   Buffer Access Strategy: normal
  Planning Time: N.N ms
  Execution Time: N.N ms
-(3 rows)
+(4 rows)
 
 select explain_filter('explain (buffers, format text) select * from int8_tbl i8');
                      explain_filter                      
@@ -119,6 +120,7 @@ explain_filter
       <Actual-Rows>N.N</Actual-Rows>
       <Actual-Loops>N</Actual-Loops>
       <Disabled>false</Disabled>
+      <Buffer-Access-Strategy>normal</Buffer-Access-Strategy>
       <Average-Prefetch-Distance>N.N</Average-Prefetch-Distance>
       <Max-Prefetch-Distance>N</Max-Prefetch-Distance>
       <Prefetch-Capacity>N</Prefetch-Capacity>
@@ -173,6 +175,7 @@ explain_filter
     Actual Rows: N.N
     Actual Loops: N
     Disabled: false
+    Buffer Access Strategy: "normal"
     Average Prefetch Distance: N.N
     Max Prefetch Distance: N
     Prefetch Capacity: N
@@ -301,65 +304,66 @@ select explain_filter('explain verbose select sum(unique1) over w1, sum(unique2)
 -- but always set in JSON format, so check them only in this case.
 set track_io_timing = on;
 select explain_filter('explain (analyze, buffers, format json) select * from int8_tbl i8');
-           explain_filter            
--------------------------------------
- [                                  +
-   {                                +
-     "Plan": {                      +
-       "Node Type": "Seq Scan",     +
-       "Parallel Aware": false,     +
-       "Async Capable": false,      +
-       "Relation Name": "int8_tbl", +
-       "Alias": "i8",               +
-       "Startup Cost": N.N,         +
-       "Total Cost": N.N,           +
-       "Plan Rows": N,              +
-       "Plan Width": N,             +
-       "Actual Startup Time": N.N,  +
-       "Actual Total Time": N.N,    +
-       "Actual Rows": N.N,          +
-       "Actual Loops": N,           +
-       "Disabled": false,           +
-       "Shared Hit Blocks": N,      +
-       "Shared Read Blocks": N,     +
-       "Shared Dirtied Blocks": N,  +
-       "Shared Written Blocks": N,  +
-       "Local Hit Blocks": N,       +
-       "Local Read Blocks": N,      +
-       "Local Dirtied Blocks": N,   +
-       "Local Written Blocks": N,   +
-       "Temp Read Blocks": N,       +
-       "Temp Written Blocks": N,    +
-       "Shared I/O Read Time": N.N, +
-       "Shared I/O Write Time": N.N,+
-       "Local I/O Read Time": N.N,  +
-       "Local I/O Write Time": N.N, +
-       "Temp I/O Read Time": N.N,   +
-       "Temp I/O Write Time": N.N   +
-     },                             +
-     "Planning": {                  +
-       "Shared Hit Blocks": N,      +
-       "Shared Read Blocks": N,     +
-       "Shared Dirtied Blocks": N,  +
-       "Shared Written Blocks": N,  +
-       "Local Hit Blocks": N,       +
-       "Local Read Blocks": N,      +
-       "Local Dirtied Blocks": N,   +
-       "Local Written Blocks": N,   +
-       "Temp Read Blocks": N,       +
-       "Temp Written Blocks": N,    +
-       "Shared I/O Read Time": N.N, +
-       "Shared I/O Write Time": N.N,+
-       "Local I/O Read Time": N.N,  +
-       "Local I/O Write Time": N.N, +
-       "Temp I/O Read Time": N.N,   +
-       "Temp I/O Write Time": N.N   +
-     },                             +
-     "Planning Time": N.N,          +
-     "Triggers": [                  +
-     ],                             +
-     "Execution Time": N.N          +
-   }                                +
+              explain_filter               
+-------------------------------------------
+ [                                        +
+   {                                      +
+     "Plan": {                            +
+       "Node Type": "Seq Scan",           +
+       "Parallel Aware": false,           +
+       "Async Capable": false,            +
+       "Relation Name": "int8_tbl",       +
+       "Alias": "i8",                     +
+       "Startup Cost": N.N,               +
+       "Total Cost": N.N,                 +
+       "Plan Rows": N,                    +
+       "Plan Width": N,                   +
+       "Actual Startup Time": N.N,        +
+       "Actual Total Time": N.N,          +
+       "Actual Rows": N.N,                +
+       "Actual Loops": N,                 +
+       "Disabled": false,                 +
+       "Buffer Access Strategy": "normal",+
+       "Shared Hit Blocks": N,            +
+       "Shared Read Blocks": N,           +
+       "Shared Dirtied Blocks": N,        +
+       "Shared Written Blocks": N,        +
+       "Local Hit Blocks": N,             +
+       "Local Read Blocks": N,            +
+       "Local Dirtied Blocks": N,         +
+       "Local Written Blocks": N,         +
+       "Temp Read Blocks": N,             +
+       "Temp Written Blocks": N,          +
+       "Shared I/O Read Time": N.N,       +
+       "Shared I/O Write Time": N.N,      +
+       "Local I/O Read Time": N.N,        +
+       "Local I/O Write Time": N.N,       +
+       "Temp I/O Read Time": N.N,         +
+       "Temp I/O Write Time": N.N         +
+     },                                   +
+     "Planning": {                        +
+       "Shared Hit Blocks": N,            +
+       "Shared Read Blocks": N,           +
+       "Shared Dirtied Blocks": N,        +
+       "Shared Written Blocks": N,        +
+       "Local Hit Blocks": N,             +
+       "Local Read Blocks": N,            +
+       "Local Dirtied Blocks": N,         +
+       "Local Written Blocks": N,         +
+       "Temp Read Blocks": N,             +
+       "Temp Written Blocks": N,          +
+       "Shared I/O Read Time": N.N,       +
+       "Shared I/O Write Time": N.N,      +
+       "Local I/O Read Time": N.N,        +
+       "Local I/O Write Time": N.N,       +
+       "Temp I/O Read Time": N.N,         +
+       "Temp I/O Write Time": N.N         +
+     },                                   +
+     "Planning Time": N.N,                +
+     "Triggers": [                        +
+     ],                                   +
+     "Execution Time": N.N                +
+   }                                      +
  ]
 (1 row)
 
@@ -436,55 +440,56 @@ select explain_filter('explain (memory, summary, format yaml) select * from int8
 (1 row)
 
 select explain_filter('explain (memory, analyze, format json) select * from int8_tbl i8');
-           explain_filter           
-------------------------------------
- [                                 +
-   {                               +
-     "Plan": {                     +
-       "Node Type": "Seq Scan",    +
-       "Parallel Aware": false,    +
-       "Async Capable": false,     +
-       "Relation Name": "int8_tbl",+
-       "Alias": "i8",              +
-       "Startup Cost": N.N,        +
-       "Total Cost": N.N,          +
-       "Plan Rows": N,             +
-       "Plan Width": N,            +
-       "Actual Startup Time": N.N, +
-       "Actual Total Time": N.N,   +
-       "Actual Rows": N.N,         +
-       "Actual Loops": N,          +
-       "Disabled": false,          +
-       "Shared Hit Blocks": N,     +
-       "Shared Read Blocks": N,    +
-       "Shared Dirtied Blocks": N, +
-       "Shared Written Blocks": N, +
-       "Local Hit Blocks": N,      +
-       "Local Read Blocks": N,     +
-       "Local Dirtied Blocks": N,  +
-       "Local Written Blocks": N,  +
-       "Temp Read Blocks": N,      +
-       "Temp Written Blocks": N    +
-     },                            +
-     "Planning": {                 +
-       "Shared Hit Blocks": N,     +
-       "Shared Read Blocks": N,    +
-       "Shared Dirtied Blocks": N, +
-       "Shared Written Blocks": N, +
-       "Local Hit Blocks": N,      +
-       "Local Read Blocks": N,     +
-       "Local Dirtied Blocks": N,  +
-       "Local Written Blocks": N,  +
-       "Temp Read Blocks": N,      +
-       "Temp Written Blocks": N,   +
-       "Memory Used": N,           +
-       "Memory Allocated": N       +
-     },                            +
-     "Planning Time": N.N,         +
-     "Triggers": [                 +
-     ],                            +
-     "Execution Time": N.N         +
-   }                               +
+              explain_filter               
+-------------------------------------------
+ [                                        +
+   {                                      +
+     "Plan": {                            +
+       "Node Type": "Seq Scan",           +
+       "Parallel Aware": false,           +
+       "Async Capable": false,            +
+       "Relation Name": "int8_tbl",       +
+       "Alias": "i8",                     +
+       "Startup Cost": N.N,               +
+       "Total Cost": N.N,                 +
+       "Plan Rows": N,                    +
+       "Plan Width": N,                   +
+       "Actual Startup Time": N.N,        +
+       "Actual Total Time": N.N,          +
+       "Actual Rows": N.N,                +
+       "Actual Loops": N,                 +
+       "Disabled": false,                 +
+       "Buffer Access Strategy": "normal",+
+       "Shared Hit Blocks": N,            +
+       "Shared Read Blocks": N,           +
+       "Shared Dirtied Blocks": N,        +
+       "Shared Written Blocks": N,        +
+       "Local Hit Blocks": N,             +
+       "Local Read Blocks": N,            +
+       "Local Dirtied Blocks": N,         +
+       "Local Written Blocks": N,         +
+       "Temp Read Blocks": N,             +
+       "Temp Written Blocks": N           +
+     },                                   +
+     "Planning": {                        +
+       "Shared Hit Blocks": N,            +
+       "Shared Read Blocks": N,           +
+       "Shared Dirtied Blocks": N,        +
+       "Shared Written Blocks": N,        +
+       "Local Hit Blocks": N,             +
+       "Local Read Blocks": N,            +
+       "Local Dirtied Blocks": N,         +
+       "Local Written Blocks": N,         +
+       "Temp Read Blocks": N,             +
+       "Temp Written Blocks": N,          +
+       "Memory Used": N,                  +
+       "Memory Allocated": N              +
+     },                                   +
+     "Planning Time": N.N,                +
+     "Triggers": [                        +
+     ],                                   +
+     "Execution Time": N.N                +
+   }                                      +
  ]
 (1 row)
 
@@ -542,6 +547,8 @@ select jsonb_pretty(
                          select * from tenk1 order by tenthous')
   -- remove "Workers" node of the Seq Scan plan node
   #- '{0,Plan,Plans,0,Plans,0,Workers}'
+  -- remove its buffer access strategy, as it depends on shared_buffers
+  #- '{0,Plan,Plans,0,Plans,0,Buffer Access Strategy}'
   -- remove "Workers" node of the Sort plan node
   #- '{0,Plan,Plans,0,Workers}'
   -- Also remove its sort-type fields, as those aren't 100% stable
@@ -767,19 +774,21 @@ select explain_filter('explain (analyze,serialize text,buffers,timing off) selec
                                   explain_filter                                   
 -----------------------------------------------------------------------------------
  Seq Scan on int8_tbl i8  (cost=N.N..N.N rows=N width=N) (actual rows=N.N loops=N)
+   Buffer Access Strategy: normal
  Planning Time: N.N ms
  Serialization: output=NkB  format=text
  Execution Time: N.N ms
-(4 rows)
+(5 rows)
 
 select explain_filter('explain (analyze,serialize binary,buffers,timing) select * from int8_tbl i8');
                                          explain_filter                                          
 -------------------------------------------------------------------------------------------------
  Seq Scan on int8_tbl i8  (cost=N.N..N.N rows=N width=N) (actual time=N.N..N.N rows=N.N loops=N)
+   Buffer Access Strategy: normal
  Planning Time: N.N ms
  Serialization: time=N.N ms  output=NkB  format=binary
  Execution Time: N.N ms
-(4 rows)
+(5 rows)
 
 -- this tests an edge case where we have no data to return
 select explain_filter('explain (analyze,buffers off,serialize) create temp table explain_temp as select * from int8_tbl i8');
diff --git a/src/test/regress/sql/explain.sql b/src/test/regress/sql/explain.sql
index 2f163c64bf6..589e14a312a 100644
--- a/src/test/regress/sql/explain.sql
+++ b/src/test/regress/sql/explain.sql
@@ -151,6 +151,8 @@ select jsonb_pretty(
                          select * from tenk1 order by tenthous')
   -- remove "Workers" node of the Seq Scan plan node
   #- '{0,Plan,Plans,0,Plans,0,Workers}'
+  -- remove its buffer access strategy, as it depends on shared_buffers
+  #- '{0,Plan,Plans,0,Plans,0,Buffer Access Strategy}'
   -- remove "Workers" node of the Sort plan node
   #- '{0,Plan,Plans,0,Workers}'
   -- Also remove its sort-type fields, as those aren't 100% stable
-- 
2.34.1

