

# Aurora PostgreSQL query plan management updates
<a name="auroraqpm.updates"></a>

The AWS `apg_plan_mgmt` extension provides your Aurora PostgreSQL DB cluster with the query plan management feature. It allows you to manage the query execution plans generated by the optimizer for your SQL applications for better stability and to prevent regressions. For more information, see [ Managing query execution plans for Aurora PostgreSQL](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraPostgreSQL.Optimize.html) in the *Amazon Aurora User Guide*. 

**Topics**
+ [PostgreSQL 17 versions](#auroraqpm-version17)
+ [PostgreSQL 16 versions](#auroraqpm-version16)
+ [PostgreSQL 15 versions](#auroraqpm-version15)
+ [PostgreSQL 14 versions](#auroraqpm-version14)
+ [PostgreSQL 13 versions](#auroraqpm-version13)
+ [PostgreSQL 12 versions](#auroraqpm-version12)
+ [Version 2.3 of the Aurora PostgreSQL apg\$1plan\$1mgmt extension](#auroraqpm-version.23)
+ [Version 2.1 of the Aurora PostgreSQL apg\$1plan\$1mgmt extension](#auroraqpm-version.21)
+ [Version 2.0 of the Aurora PostgreSQL apg\$1plan\$1mgmt extension](#auroraqpm-version.20)
+ [Version 1.0.1 of the Aurora PostgreSQL apg\$1plan\$1mgmt extension](#auroraqpm-version.101)

## PostgreSQL 17 versions
<a name="auroraqpm-version17"></a>

**Topics**
+ [apg\$1plan\$1mgmt version 2.9 for Aurora PostgreSQL 17.9, April 6, 2026](#auroraqpm-version17-179)
+ [apg\$1plan\$1mgmt version 2.9 for Aurora PostgreSQL 17.7, December 18, 2025](#auroraqpm-version17-177)
+ [apg\$1plan\$1mgmt version 2.9 for Aurora PostgreSQL 17.5, June 30, 2025](#auroraqpm-version17-175)
+ [apg\$1plan\$1mgmt version 2.8 for Aurora PostgreSQL 17.4, May 01, 2025](#auroraqpm-version17-174)

### apg\$1plan\$1mgmt version 2.9 for Aurora PostgreSQL 17.9, April 6, 2026
<a name="auroraqpm-version17-179"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.9 for Aurora PostgreSQL 17.9 include the following:

**Extension improvements**
+ Fixed an issue in Query Plan Management that caused plans to not be captured.

### apg\$1plan\$1mgmt version 2.9 for Aurora PostgreSQL 17.7, December 18, 2025
<a name="auroraqpm-version17-177"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.9 for Aurora PostgreSQL 17.7 include the following:

**Extension improvements**
+ Added an improvement in Query Plan Management to automatically recapture parameter lists that are stored from previous versions.

### apg\$1plan\$1mgmt version 2.9 for Aurora PostgreSQL 17.5, June 30, 2025
<a name="auroraqpm-version17-175"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.9 for Aurora PostgreSQL 17.5 include the following:

**Additional improvements and enhancements**
+ Fixed an issue in query plan management with enforcement of Parallel Bitmap Scans when a BitmapOr/BitmapAnd operator is present.
+ Fixed an issue in query plan management with enforcement of plans where multiple table partitions are joined to one table partition.
+ Fixed an issue in query plan management with enforcement of Append nodes on top of a single table partition.
+ The `apg_plan_mgmt` role in query plan management is reserved and can no longer be created, altered or dropped by users.
+ Fixed an issue in handling parameter lists from previous versions of query plan management.

### apg\$1plan\$1mgmt version 2.8 for Aurora PostgreSQL 17.4, May 01, 2025
<a name="auroraqpm-version17-174"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.8 for Aurora PostgreSQL 17.4 include the following:

**New features**
+ Query plan management can enforce plans having correlated subquery transformation.
+ Query plan management can enforce plans having correlated subquery cache.

**Additional improvements and enhancements**
+ Fixed an issue with parameter list that caused an error or restart while querying `dba_plans` view or calling `validate_plans` and `evolve_plan_baselines` functions in Query plan management. 
+ Fixed an issue with enforcement of plans optimized by correlated any transform in Query plan management.
+ Fixed an issue in query plan management with running a utility statement immediately after installing the extension or resetting shared memory.
+ Fixed an issue in enforcing, validating and evolving plans for queries with calls to immutable functions in query plan management.
+ Fixed an issue in enforcing, validating and evolving plans in query plan management.

## PostgreSQL 16 versions
<a name="auroraqpm-version16"></a>

**Topics**
+ [apg\$1plan\$1mgmt version 2.9 for Aurora PostgreSQL 16.13, April 6, 2026](#auroraqpm-version16-1613)
+ [apg\$1plan\$1mgmt version 2.9 for Aurora PostgreSQL 16.11, December 18, 2025](#auroraqpm-version16-1611)
+ [apg\$1plan\$1mgmt version 2.9 for Aurora PostgreSQL 16.9, June 30, 2025](#auroraqpm-version16-169)
+ [apg\$1plan\$1mgmt version 2.8 for Aurora PostgreSQL 16.8, April 8, 2025](#auroraqpm-version16-168)
+ [apg\$1plan\$1mgmt version 2.7 for Aurora PostgreSQL 16.6, December 27, 2024](#auroraqpm-version16-166)
+ [apg\$1plan\$1mgmt version 2.7 for Aurora PostgreSQL 16.3](#auroraqpm-version16-163)
+ [apg\$1plan\$1mgmt version 2.6 for Aurora PostgreSQL 16.2](#auroraqpm-version16-162)
+ [apg\$1plan\$1mgmt version 2.6 for Aurora PostgreSQL 16.1](#auroraqpm-version16-161)

### apg\$1plan\$1mgmt version 2.9 for Aurora PostgreSQL 16.13, April 6, 2026
<a name="auroraqpm-version16-1613"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.9 for Aurora PostgreSQL 16.13 include the following:

**Extension improvements**
+ Fixed an issue in Query Plan Management that caused plans to not be captured.

### apg\$1plan\$1mgmt version 2.9 for Aurora PostgreSQL 16.11, December 18, 2025
<a name="auroraqpm-version16-1611"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.9 for Aurora PostgreSQL 16.11 include the following:

**Extension improvements**
+ Added an improvement in Query Plan Management to automatically recapture parameter lists that are stored from previous versions.

### apg\$1plan\$1mgmt version 2.9 for Aurora PostgreSQL 16.9, June 30, 2025
<a name="auroraqpm-version16-169"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.9 for Aurora PostgreSQL 16.9 include the following:

**Additional improvements and enhancements**
+ Fixed an issue in query plan management with enforcement of Parallel Bitmap Scans when a BitmapOr/BitmapAnd operator is present.
+ Fixed an issue in query plan management with enforcement of plans where multiple table partitions are joined to one table partition.
+ Fixed an issue in query plan management with enforcement of Append nodes on top of a single table partition.
+ The `apg_plan_mgmt` role in query plan management is reserved and can no longer be created, altered or dropped by users.
+ Fixed an issue in handling parameter lists from previous versions of query plan management.

### apg\$1plan\$1mgmt version 2.8 for Aurora PostgreSQL 16.8, April 8, 2025
<a name="auroraqpm-version16-168"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.8 for Aurora PostgreSQL 16.8 include the following:

**New features**
+ Query plan management can enforce plans having correlated subquery transformation.
+ Query plan management can enforce plans having correlated subquery cache.

**Additional improvements and enhancements**
+ Fixed an issue with parameter list that caused an error or restart while querying `dba_plans` view or calling `validate_plans` and `evolve_plan_baselines` functions in Query plan management. 
+ Fixed an issue with enforcement of plans optimized by correlated any transform in Query plan management.
+ Fixed an issue in Query plan management with running a utility statement immediately after installing the extension or resetting shared memory.
+ Fixed an issue in enforcing, validating and evolving plans for queries with calls to immutable functions in Query plan management.
+ Fixed an issue in enforcing, validating and evolving plans in Query plan management.

### apg\$1plan\$1mgmt version 2.7 for Aurora PostgreSQL 16.6, December 27, 2024
<a name="auroraqpm-version16-166"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.7 for Aurora PostgreSQL 16.6 include the following:

**Additional improvements and enhancements**
+ Fixed an issue with plan capture on replica in query plan management where the shared memory array in the replica would become full.
+ Fixed an issue with query plan management background worker that caused plan retention period to not be enforced and last used date to not be updated.
+ Fixed an issue related to query plan management background worker.
+ Fixed an issue with enforcement of query plan management plans containing bitmap scans.
+ Fixed an issue with query plan management where plans were captured incorrectly for functions or procedure with multiple queries.
+ Fixed an issue with capturing plans of nested query executions in query plan management. 
+ Fixed an issue with capturing plans in query plan management with extended query protocol. 

### apg\$1plan\$1mgmt version 2.7 for Aurora PostgreSQL 16.3
<a name="auroraqpm-version16-163"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.7 for Aurora PostgreSQL 16.3 include the following:

**New features**
+ You no longer need to update the `plan_hash_version`. After upgrading the database engine, QPM automatically enables new features. You don't need to take any action for new features to become available.

**Additional improvements and enhancements**
+ Fixed an issue with enforcement of QPM plans containing more than 64 partitioned tables.
+ Fixed an issue with enforcement of QPM plans containing the Append operator.
+ Fixed an issue with QPM validate\$1plans with update\$1plan\$1hash action.

### apg\$1plan\$1mgmt version 2.6 for Aurora PostgreSQL 16.2
<a name="auroraqpm-version16-162"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.6 for Aurora PostgreSQL 16.2 include the following:

**New features**
+ QPM can enforce plans having Aggregate operators.

**Additional improvements and enhancements**
+ Fixed an issue where dropping a database did not remove associated captured plans from shared memory.
+ Fixed an issue with enforcement of plans containing views.
+ Improvements in Parallel Append plan enforcement.
+ Fixed an issue related to plan capture.
+ Fixed an issue with enforcement of plans containing gather nodes.

### apg\$1plan\$1mgmt version 2.6 for Aurora PostgreSQL 16.1
<a name="auroraqpm-version16-161"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.6 for Aurora PostgreSQL 16.1 include the following:

**New features**
+ Plan outlines will be updated to the latest format version as part of the `update_plan_hash` action for `apg_plan_mgmt.validate_plans` function.
+ Added support for parallel Append enforcement as a part of Parallel Query Enforcement. To enforce parallel append nodes correctly, you must do the following:

  1. Set `apg_plan_mgmt.plan_hash_version` to 5.

  1. Call `apg_plan_mgmt.validate_plans('update_plan_hash')`.

**Additional improvements and enhancements**
+ Performance improvement in plan hash calculation. 
+ Enhanced memory utilization for plan outlines that contain repetitive subplans.
+ Fixed an issue in parallel query enforcement where `GatherMerge` could not be enforced.
+ Fixed an issue where estimated cost of enforced plan was incorrect.
+ Fixed an issue in enforcement of approved plans where the outline contains partitioned tables and subplans.

## PostgreSQL 15 versions
<a name="auroraqpm-version15"></a>

**Topics**
+ [apg\$1plan\$1mgmt version 2.9 for Aurora PostgreSQL 15.17, April 6, 2026](#auroraqpm-version15-1517)
+ [apg\$1plan\$1mgmt version 2.9 for Aurora PostgreSQL 15.15, December 18, 2025](#auroraqpm-version15-1515)
+ [apg\$1plan\$1mgmt version 2.9 for Aurora PostgreSQL 15.13, June 30, 2025](#auroraqpm-version15-1513)
+ [apg\$1plan\$1mgmt version 2.8 for Aurora PostgreSQL 15.12, April 8, 2025](#auroraqpm-version15-1512)
+ [apg\$1plan\$1mgmt version 2.7 for Aurora PostgreSQL 15.10, December 27, 2024](#auroraqpm-version15-1510)
+ [apg\$1plan\$1mgmt version 2.7 for Aurora PostgreSQL 15.8, September 30, 2024](#auroraqpm-version15-158)
+ [apg\$1plan\$1mgmt version 2.7 for Aurora PostgreSQL 15.7, August 8, 2024](#auroraqpm-version15-157)
+ [apg\$1plan\$1mgmt version 2.6 for Aurora PostgreSQL 15.6](#auroraqpm-version15-156)
+ [apg\$1plan\$1mgmt version 2.6 for Aurora PostgreSQL 15.5](#auroraqpm-version15-155)
+ [apg\$1plan\$1mgmt version 2.5 for Aurora PostgreSQL 15.4](#auroraqpm-version15-154)
+ [apg\$1plan\$1mgmt version 2.4 for Aurora PostgreSQL 15.3](#auroraqpm-version15-153)

### apg\$1plan\$1mgmt version 2.9 for Aurora PostgreSQL 15.17, April 6, 2026
<a name="auroraqpm-version15-1517"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.9 for Aurora PostgreSQL 15.17 include the following:

**Extension improvements**
+ Fixed an issue in Query Plan Management that caused plans to not be captured.

### apg\$1plan\$1mgmt version 2.9 for Aurora PostgreSQL 15.15, December 18, 2025
<a name="auroraqpm-version15-1515"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.9 for Aurora PostgreSQL 15.15 include the following:

**Extension improvements**
+ Added an improvement in Query Plan Management to automatically recapture parameter lists that are stored from previous versions.

### apg\$1plan\$1mgmt version 2.9 for Aurora PostgreSQL 15.13, June 30, 2025
<a name="auroraqpm-version15-1513"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.9 for Aurora PostgreSQL 15.13 include the following:

**Additional improvements and enhancements**
+ Fixed an issue in query plan management with enforcement of Parallel Bitmap Scans when a BitmapOr/BitmapAnd operator is present.
+ Fixed an issue in query plan management with enforcement of plans where multiple table partitions are joined to one table partition.
+ Fixed an issue in query plan management with enforcement of Append nodes on top of a single table partition.
+ The `apg_plan_mgmt` role in query plan management is reserved and can no longer be created, altered or dropped by users.
+ Fixed an issue in handling parameter lists from previous versions of query plan management.

### apg\$1plan\$1mgmt version 2.8 for Aurora PostgreSQL 15.12, April 8, 2025
<a name="auroraqpm-version15-1512"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.8 for Aurora PostgreSQL 15.12 include the following:

**Additional improvements and enhancements**
+ Fixed an issue with parameter list that caused an error or restart while querying `dba_plans` view or calling `validate_plans` and `evolve_plan_baselines` functions in Query plan management. 
+ Fixed an issue with enforcement of plans optimized by correlated any transform in Query plan management.
+ Fixed an issue in Query plan management with running a utility statement immediately after installing the extension or resetting shared memory.
+ Fixed an issue in enforcing, validating and evolving plans for queries with calls to immutable functions in Query plan management.
+ Fixed an issue in enforcing, validating and evolving plans in Query plan management.

### apg\$1plan\$1mgmt version 2.7 for Aurora PostgreSQL 15.10, December 27, 2024
<a name="auroraqpm-version15-1510"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.7 for Aurora PostgreSQL 15.10 include the following:

**Additional improvements and enhancements**
+ Fixed an issue with plan capture on replica in query plan management where the shared memory array in the replica would become full.
+ Fixed an issue with query plan management background worker that caused plan retention period to not be enforced and last used date to not be updated.
+ Fixed an issue related to query plan management background worker.
+ Fixed an issue with enforcement of query plan management plans containing bitmap scans.
+ Fixed an issue with query plan management where plans were captured incorrectly for functions or procedure with multiple queries.
+ Fixed an issue with capturing plans of nested query executions in query plan management. 
+ Fixed an issue with capturing plans in query plan management with extended query protocol. 

### apg\$1plan\$1mgmt version 2.7 for Aurora PostgreSQL 15.8, September 30, 2024
<a name="auroraqpm-version15-158"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.7 for Aurora PostgreSQL 15.8 include the following:

**Additional improvements and enhancements**
+ Fixed an issue with enforcement of Query Plan Management plans containing Hash Aggregates.

### apg\$1plan\$1mgmt version 2.7 for Aurora PostgreSQL 15.7, August 8, 2024
<a name="auroraqpm-version15-157"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.7 for Aurora PostgreSQL 15.7 include the following:

**New features**
+ You no longer need to update the `plan_hash_version`. After upgrading the database engine, QPM automatically enables new features. You don't need to take any action for new features to become available.

**Additional improvements and enhancements**
+ Fixed an issue with enforcement of QPM plans containing more than 64 partitioned tables.
+ Fixed an issue with enforcement of QPM plans containing the Append operator.
+ Fixed an issue with QPM validate\$1plans with update\$1plan\$1hash action.

### apg\$1plan\$1mgmt version 2.6 for Aurora PostgreSQL 15.6
<a name="auroraqpm-version15-156"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.6 for Aurora PostgreSQL 15.6 include the following:

**New features**
+ QPM can enforce plans having Aggregate operators.

**Additional improvements and enhancements**
+ Fixed an issue where dropping a database did not remove associated captured plans from shared memory.
+ Fixed an issue with enforcement of plans containing views.
+ Improvements in Parallel Append plan enforcement.
+ Fixed an issue related to plan capture.
+ Fixed an issue with enforcement of plans containing gather nodes.

### apg\$1plan\$1mgmt version 2.6 for Aurora PostgreSQL 15.5
<a name="auroraqpm-version15-155"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.6 for Aurora PostgreSQL 15.5 include the following:

**New features**
+ Plan outlines will be updated to the latest format version as part of the `update_plan_hash` action for `apg_plan_mgmt.validate_plans` function.
+ Added support for parallel Append enforcement as a part of Parallel Query Enforcement. To enforce parallel append nodes correctly, you must do the following:

  1. Set `apg_plan_mgmt.plan_hash_version` to 5.

  1. Call `apg_plan_mgmt.validate_plans('update_plan_hash')`.

**Additional improvements and enhancements**
+ Performance improvement in plan hash calculation. 
+ Enhanced memory utilization for plan outlines that contain repetitive subplans.
+ Fixed an issue in parallel query enforcement where `GatherMerge` could not be enforced.
+ Fixed an issue where estimated cost of enforced plan was incorrect.
+ Fixed an issue in enforcement of approved plans where the outline contains partitioned tables and subplans.

### apg\$1plan\$1mgmt version 2.5 for Aurora PostgreSQL 15.4
<a name="auroraqpm-version15-154"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.5 for Aurora PostgreSQL 15.4 include the following:

**New features**
+ QPM can enforce query plans to have parallel operators except Parallel Append node. To enforce parallel query plans correctly, you must do the following after upgrading to 15.4 or 14.9:
  + Set `apg_plan_mgmt.plan_hash_version` to 4 or above.
  + Call `apg_plan_mgmt.validate_plans('update_plan_hash')`.
  + Re-capture approved plans that has Gather node in plan\$1outline.
+ QPM can enforce query plans with Materialize nodes. To enforce Materialize nodes, you must do the following after upgrading to 15.4 or 14.9:
  + Set `apg_plan_mgmt.plan_hash_version` to 4 or above.
  + Call `apg_plan_mgmt.validate_plans('update_plan_hash')`.
+ To capture query plans from Replicas, you must update `apg_plan_mgmt` extension by calling ALTER EXTENSION apg\$1plan\$1mgmt UPDATE. 
+ You need to specify `apg_plan_mgmt.plan_capture_threshold` in order to not allow QPM to capture any query plans.

**Additional improvements and enhancements**
+ Performance improvement on `plan_hash` calculation.

### apg\$1plan\$1mgmt version 2.4 for Aurora PostgreSQL 15.3
<a name="auroraqpm-version15-153"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.4 for Aurora PostgreSQL 15.3 include the following:

**New features**
+ Introduced a new GUC auto\$1explain.hashes. When it is set to true (default: false), sql\$1hash and plan\$1hash are shown at the end of auto explain result. 
+ Introduced a new GUC apg\$1plan\$1mgmt.explain\$1hashes. When it is set to true (default: false), EXPLAIN result shows sql\$1hash and plan\$1hash even without hashes true option.
+ Introduced a new GUC apg\$1plan\$1mgmt.log\$1plan\$1enforcement\$1result. Depending on its value (default: none), plan enforcement results are written to Postgres log files.
+ Introduced a new plan hash calculation version to support partitioned tables. Users need to set apg\$1plan\$1mgmt.plan\$1hash\$1version to 3 and call apg\$1plan\$1mgmt.validate\$1plans('update\$1plan\$1hash') in each database with `apg_plan_mgmt` installed and entries in the plans table.
+ QPM can enforce query plans with Memoize nodes.
+  The `apg_plan_mgmt.copy_outline` function can take a new 5th argument, `force_update_target_plan_hash`. If it is set to true, the target plan hash will be updated even though the source plan isn't reproducible for the target sql\$1hash. 

**Additional improvements and enhancements**
+ Fixed an issue with JDBC prepared statements plan enforcement.
+ Improved parity regarding queryid between pg\$1stat\$1statements and apg\$1plan\$1mgmt.dba\$1plans.
+ Fixed a plan enforcement issue when index names end with digits. 
+  The apg\$1plan\$1mgmt.copy\$1outline function now copies environment\$1variables. 
+  The minimum value of apg\$1plan\$1mgmt.plan\$1retention\$1period changes to 1 from 32. 
+  The query plan management can now save plans for queries in read-only transactions from the writer nodes. 
+  Fixed an issue in the apg\$1plan\$1mgmt.evolve\$1plan\$1baselines function. 
+  Fixed an issue that could cause unavailability when the apg\$1plan\$1mgmt is enabled. 

To learn how to install, upgrade, and use the `apg_plan_mgmt` extension, see [ Managing query execution plans for Aurora PostgreSQL](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraPostgreSQL.Optimize.html) in the *Amazon Aurora User Guide*.

## PostgreSQL 14 versions
<a name="auroraqpm-version14"></a>

**Topics**
+ [apg\$1plan\$1mgmt version 2.9 for Aurora PostgreSQL 14.22, April 6, 2026](#auroraqpm-version14-1422)
+ [apg\$1plan\$1mgmt version 2.9 for Aurora PostgreSQL 14.20, December 18, 2025](#auroraqpm-version14-1420)
+ [apg\$1plan\$1mgmt version 2.9 for Aurora PostgreSQL 14.18, June 30, 2025](#auroraqpm-version14-1418)
+ [apg\$1plan\$1mgmt version 2.8 for Aurora PostgreSQL 14.17, April 8, 2025](#auroraqpm-version14-1417)
+ [apg\$1plan\$1mgmt version 2.7 for Aurora PostgreSQL 14.15, December 27, 2024](#auroraqpm-version14-1415)
+ [apg\$1plan\$1mgmt version 2.7 for Aurora PostgreSQL 14.12, August 8, 2024](#auroraqpm-version14-1412)
+ [apg\$1plan\$1mgmt version 2.6 for Aurora PostgreSQL 14.11](#auroraqpm-version14-1411)
+ [apg\$1plan\$1mgmt version 2.6 for Aurora PostgreSQL 14.10](#auroraqpm-version14-1410)
+ [apg\$1plan\$1mgmt version 2.5 for Aurora PostgreSQL 14.9](#auroraqpm-version14-149)
+ [apg\$1plan\$1mgmt version 2.4 for Aurora PostgreSQL 14.8](#auroraqpm-version14-148)

### apg\$1plan\$1mgmt version 2.9 for Aurora PostgreSQL 14.22, April 6, 2026
<a name="auroraqpm-version14-1422"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.9 for Aurora PostgreSQL 14.22 include the following:

**Extension improvements**
+ Fixed an issue in Query Plan Management that caused plans to not be captured.

### apg\$1plan\$1mgmt version 2.9 for Aurora PostgreSQL 14.20, December 18, 2025
<a name="auroraqpm-version14-1420"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.9 for Aurora PostgreSQL 14.20 include the following:

**Extension improvements**
+ Added an improvement in Query Plan Management to automatically recapture parameter lists that are stored from previous versions.

### apg\$1plan\$1mgmt version 2.9 for Aurora PostgreSQL 14.18, June 30, 2025
<a name="auroraqpm-version14-1418"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.9 for Aurora PostgreSQL 14.18 include the following:

**Additional improvements and enhancements**
+ Fixed an issue in query plan management with enforcement of Parallel Bitmap Scans when a BitmapOr/BitmapAnd operator is present.
+ Fixed an issue in query plan management with enforcement of plans where multiple table partitions are joined to one table partition.
+ Fixed an issue in query plan management with enforcement of Append nodes on top of a single table partition.
+ The `apg_plan_mgmt` role in query plan management is reserved and can no longer be created, altered or dropped by users.
+ Fixed an issue in handling parameter lists from previous versions of query plan management.

### apg\$1plan\$1mgmt version 2.8 for Aurora PostgreSQL 14.17, April 8, 2025
<a name="auroraqpm-version14-1417"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.8 for Aurora PostgreSQL 14.17 include the following:

**Additional improvements and enhancements**
+ Fixed an issue with parameter list that caused an error or restart while querying `dba_plans` view or calling `validate_plans` and `evolve_plan_baselines` functions in Query plan management. 
+ Fixed an issue with enforcement of plans optimized by correlated any transform in Query plan management.
+ Fixed an issue in Query plan management with running a utility statement immediately after installing the extension or resetting shared memory.
+ Fixed an issue in enforcing, validating and evolving plans for queries with calls to immutable functions in Query plan management.
+ Fixed an issue in enforcing, validating and evolving plans in Query plan management.

### apg\$1plan\$1mgmt version 2.7 for Aurora PostgreSQL 14.15, December 27, 2024
<a name="auroraqpm-version14-1415"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.7 for Aurora PostgreSQL 14.15 include the following:

**Additional improvements and enhancements**
+ Fixed an issue with plan capture on replica in query plan management where the shared memory array in the replica would become full.
+ Fixed an issue with query plan management background worker that caused plan retention period to not be enforced and last used date to not be updated.
+ Fixed an issue related to query plan management background worker.
+ Fixed an issue with enforcement of query plan management plans containing bitmap scans.
+ Fixed an issue with query plan management where plans were captured incorrectly for functions or procedure with multiple queries.
+ Fixed an issue with capturing plans of nested query executions in query plan management. 
+ Fixed an issue with capturing plans in query plan management with extended query protocol. 

### apg\$1plan\$1mgmt version 2.7 for Aurora PostgreSQL 14.12, August 8, 2024
<a name="auroraqpm-version14-1412"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.7 for Aurora PostgreSQL 14.12 include the following:

**New features**
+ You no longer need to update the `plan_hash_version`. After upgrading the database engine, QPM automatically enables new features. You don't need to take any action for new features to become available.

**Additional improvements and enhancements**
+ Fixed an issue with enforcement of QPM plans containing more than 64 partitioned tables.
+ Fixed an issue with enforcement of QPM plans containing the Append operator.
+ Fixed an issue with QPM validate\$1plans with update\$1plan\$1hash action.

### apg\$1plan\$1mgmt version 2.6 for Aurora PostgreSQL 14.11
<a name="auroraqpm-version14-1411"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.6 for Aurora PostgreSQL 14.11 include the following:

**New features**
+ QPM can enforce plans having Aggregate operators.

**Additional improvements and enhancements**
+ Fixed an issue where dropping a database did not remove associated captured plans from shared memory.
+ Fixed an issue with enforcement of plans containing views.
+ Improvements in Parallel Append plan enforcement.
+ Fixed an issue related to plan capture.
+ Fixed an issue with enforcement of plans containing gather nodes.

### apg\$1plan\$1mgmt version 2.6 for Aurora PostgreSQL 14.10
<a name="auroraqpm-version14-1410"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.6 for Aurora PostgreSQL 14.10 include the following:

**New features**
+ Plan outlines will be updated to the latest format version as part of the `update_plan_hash` action for `apg_plan_mgmt.validate_plans` function.
+ Added support for parallel Append enforcement as a part of Parallel Query Enforcement. To enforce parallel append nodes correctly, you must do the following:

  1. Set `apg_plan_mgmt.plan_hash_version` to 5.

  1. Call `apg_plan_mgmt.validate_plans('update_plan_hash')`.

**Additional improvements and enhancements**
+ Performance improvement in plan hash calculation. 
+ Enhanced memory utilization for plan outlines that contain repetitive subplans.
+ Fixed an issue in parallel query enforcement where `GatherMerge` could not be enforced.
+ Fixed an issue where estimated cost of enforced plan was incorrect.
+ Fixed an issue in enforcement of approved plans where the outline contains partitioned tables and subplans.

### apg\$1plan\$1mgmt version 2.5 for Aurora PostgreSQL 14.9
<a name="auroraqpm-version14-149"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.5 for Aurora PostgreSQL 14.9 include the following:

**New features**
+ QPM can enforce query plans to have parallel operators except Parallel Append node. To enforce parallel query plans correctly, you must do the following after upgrading to 15.4 or 14.9:
  + Set `apg_plan_mgmt.plan_hash_version` to 4 or above.
  + Call `apg_plan_mgmt.validate_plans('update_plan_hash')`.
  + Re-capture approved plans that has Gather node in plan\$1outline.
+ QPM can enforce query plans with Materialize nodes. To enforce Materialize nodes, you must do the following after upgrading to 15.4 or 14.9:
  + Set `apg_plan_mgmt.plan_hash_version` to 4 or above.
  + Call `apg_plan_mgmt.validate_plans('update_plan_hash')`.
+ To capture query plans from Replicas, you must update `apg_plan_mgmt` extension by calling ALTER EXTENSION apg\$1plan\$1mgmt UPDATE. 
+ You need to specify `apg_plan_mgmt.plan_capture_threshold` in order to not allow QPM to capture any query plans.

**Additional improvements and enhancements**
+ Performance improvement on `plan_hash` calculation.

### apg\$1plan\$1mgmt version 2.4 for Aurora PostgreSQL 14.8
<a name="auroraqpm-version14-148"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.4 for Aurora PostgreSQL 14.8 include the following:

**New features**
+ Introduced a new GUC auto\$1explain.hashes. When it is set to true (default: false), sql\$1hash and plan\$1hash are shown at the end of auto explain result. 
+ Introduced a new GUC apg\$1plan\$1mgmt.explain\$1hashes. When it is set to true (default: false), EXPLAIN result shows sql\$1hash and plan\$1hash even without hashes true option.
+ Introduced a new GUC apg\$1plan\$1mgmt.log\$1plan\$1enforcement\$1result. Depending on its value (default: none), plan enforcement results are written to Postgres log files.
+ Introduced a new plan hash calculation version to support partitioned tables. Users need to set apg\$1plan\$1mgmt.plan\$1hash\$1version to 3 and call apg\$1plan\$1mgmt.validate\$1plans('update\$1plan\$1hash') in each database with `apg_plan_mgmt` installed and entries in the plans table.
+ QPM can enforce query plans with Memoize nodes.
+  The `apg_plan_mgmt.copy_outline` function can take a new 5th argument, `force_update_target_plan_hash`. If it is set to true, the target plan hash will be updated even though the source plan isn't reproducible for the target sql\$1hash. 

**Additional improvements and enhancements**
+ Fixed an issue with JDBC prepared statements plan enforcement.
+ Improved parity regarding queryid between pg\$1stat\$1statements and apg\$1plan\$1mgmt.dba\$1plans.
+ Fixed a plan enforcement issue when index names end with digits. 
+  The apg\$1plan\$1mgmt.copy\$1outline function now copies environment\$1variables. 
+  The minimum value of apg\$1plan\$1mgmt.plan\$1retention\$1period changes to 1 from 32. 
+  The query plan management can now save plans for queries in read-only transactions from the writer nodes. 
+  Fixed an issue in the apg\$1plan\$1mgmt.evolve\$1plan\$1baselines function. 
+  Fixed an issue that could cause unavailability when the apg\$1plan\$1mgmt is enabled. 

To learn how to install, upgrade, and use the `apg_plan_mgmt` extension, see [ Managing query execution plans for Aurora PostgreSQL](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraPostgreSQL.Optimize.html) in the *Amazon Aurora User Guide*.

## PostgreSQL 13 versions
<a name="auroraqpm-version13"></a>

**Topics**
+ [apg\$1plan\$1mgmt version 2.9 for Aurora PostgreSQL 13.23, December 18, 2025](#auroraqpm-version13-1323)
+ [apg\$1plan\$1mgmt version 2.9 for Aurora PostgreSQL 13.21, June 30, 2025](#auroraqpm-version13-1321)
+ [apg\$1plan\$1mgmt version 2.8 for Aurora PostgreSQL 13.20, April 8, 2025](#auroraqpm-version13-1320)
+ [apg\$1plan\$1mgmt version 2.7 for Aurora PostgreSQL 13.18, December 27, 2024](#auroraqpm-version13-1318)
+ [apg\$1plan\$1mgmt version 2.7 for Aurora PostgreSQL 13.15, August 8, 2024](#auroraqpm-version13-1315)
+ [apg\$1plan\$1mgmt version 2.6 for Aurora PostgreSQL 13.14](#auroraqpm-version13-1314)
+ [apg\$1plan\$1mgmt version 2.6 for Aurora PostgreSQL 13.13](#auroraqpm-version13-1313)
+ [apg\$1plan\$1mgmt version 2.5 for Aurora PostgreSQL 13.12](#auroraqpm-version13-1312)
+ [apg\$1plan\$1mgmt version 2.4 for Aurora PostgreSQL 13.11](#auroraqpm-version13-1311)

### apg\$1plan\$1mgmt version 2.9 for Aurora PostgreSQL 13.23, December 18, 2025
<a name="auroraqpm-version13-1323"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.9 for Aurora PostgreSQL 13.23 include the following:

**Extension improvements**
+ Added an improvement in Query Plan Management to automatically recapture parameter lists that are stored from previous versions.

### apg\$1plan\$1mgmt version 2.9 for Aurora PostgreSQL 13.21, June 30, 2025
<a name="auroraqpm-version13-1321"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.9 for Aurora PostgreSQL 13.21 include the following:

**Additional improvements and enhancements**
+ Fixed an issue in query plan management with enforcement of Parallel Bitmap Scans when a BitmapOr/BitmapAnd operator is present.
+ Fixed an issue in query plan management with enforcement of plans where multiple table partitions are joined to one table partition.
+ Fixed an issue in query plan management with enforcement of Append nodes on top of a single table partition.
+ The `apg_plan_mgmt` role in Query Plan Management is reserved and can no longer be created, altered or dropped by users.
+ Fixed an issue in handling parameter lists from previous versions of Query Plan Management.

### apg\$1plan\$1mgmt version 2.8 for Aurora PostgreSQL 13.20, April 8, 2025
<a name="auroraqpm-version13-1320"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.8 for Aurora PostgreSQL 13.20 include the following:

**Additional improvements and enhancements**
+ Fixed an issue with parameter list that caused an error or restart while querying `dba_plans` view or calling `validate_plans` and `evolve_plan_baselines` functions in Query plan management. 
+ Fixed an issue with enforcement of plans optimized by correlated any transform in Query plan management.
+ Fixed an issue in Query plan management with running a utility statement immediately after installing the extension or resetting shared memory.
+ Fixed an issue in enforcing, validating and evolving plans for queries with calls to immutable functions in Query plan management.
+ Fixed an issue in enforcing, validating and evolving plans in Query plan management.

### apg\$1plan\$1mgmt version 2.7 for Aurora PostgreSQL 13.18, December 27, 2024
<a name="auroraqpm-version13-1318"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.7 for Aurora PostgreSQL 13.18 include the following:

**Additional improvements and enhancements**
+ Fixed an issue with plan capture on replica in query plan management where the shared memory array in the replica would become full.
+ Fixed an issue with query plan management background worker that caused plan retention period to not be enforced and last used date to not be updated.
+ Fixed an issue related to query plan management background worker.
+ Fixed an issue with enforcement of query plan management plans containing bitmap scans.
+ Fixed an issue with query plan management where plans were captured incorrectly for functions or procedure with multiple queries.
+ Fixed an issue with capturing plans of nested query executions in query plan management. 
+ Fixed an issue with capturing plans in query plan management with extended query protocol. 

### apg\$1plan\$1mgmt version 2.7 for Aurora PostgreSQL 13.15, August 8, 2024
<a name="auroraqpm-version13-1315"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.7 for Aurora PostgreSQL 13.15 include the following:

**New features**
+ You no longer need to update the `plan_hash_version`. After upgrading the database engine, QPM automatically enables new features. You don't need to take any action for new features to become available.

**Additional improvements and enhancements**
+ Fixed an issue with enforcement of QPM plans containing more than 64 partitioned tables.
+ Fixed an issue with enforcement of QPM plans containing the Append operator.
+ Fixed an issue with QPM validate\$1plans with update\$1plan\$1hash action.

### apg\$1plan\$1mgmt version 2.6 for Aurora PostgreSQL 13.14
<a name="auroraqpm-version13-1314"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.6 for Aurora PostgreSQL 13.14 include the following:

**New features**
+ QPM can enforce plans having Aggregate operators.

**Additional improvements and enhancements**
+ Fixed an issue where dropping a database did not remove associated captured plans from shared memory.
+ Fixed an issue with enforcement of plans containing views.
+ Improvements in Parallel Append plan enforcement.
+ Fixed an issue related to plan capture.
+ Fixed an issue with enforcement of plans containing gather nodes.

### apg\$1plan\$1mgmt version 2.6 for Aurora PostgreSQL 13.13
<a name="auroraqpm-version13-1313"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.6 for Aurora PostgreSQL 13.13 include the following:

**New features**
+ Plan outlines will be updated to the latest format version as part of the `update_plan_hash` action for `apg_plan_mgmt.validate_plans` function.
+ Added support for parallel Append enforcement as a part of Parallel Query Enforcement. To enforce parallel append nodes correctly, you must do the following:

  1. Set `apg_plan_mgmt.plan_hash_version` to 5.

  1. Call `apg_plan_mgmt.validate_plans('update_plan_hash')`.

**Additional improvements and enhancements**
+ Performance improvement in plan hash calculation. 
+ Enhanced memory utilization for plan outlines that contain repetitive subplans.
+ Fixed an issue in parallel query enforcement where `GatherMerge` could not be enforced.
+ Fixed an issue where estimated cost of enforced plan was incorrect.
+ Fixed an issue in enforcement of approved plans where the outline contains partitioned tables and subplans.

### apg\$1plan\$1mgmt version 2.5 for Aurora PostgreSQL 13.12
<a name="auroraqpm-version13-1312"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.5 for Aurora PostgreSQL 13.12 include the following:

**New features**
+ QPM can enforce query plans to have parallel operators except Parallel Append node. To enforce parallel query plans correctly, you must do the following after upgrading to 15.4 or 14.9:
  + Set `apg_plan_mgmt.plan_hash_version` to 4 or above.
  + Call `apg_plan_mgmt.validate_plans('update_plan_hash')`.
  + Re-capture approved plans that has Gather node in plan\$1outline.
+ To capture query plans from Replicas, you must update `apg_plan_mgmt` extension by calling ALTER EXTENSION apg\$1plan\$1mgmt UPDATE. 
+ You need to specify `apg_plan_mgmt.plan_capture_threshold` in order to not allow QPM to capture any query plans.

### apg\$1plan\$1mgmt version 2.4 for Aurora PostgreSQL 13.11
<a name="auroraqpm-version13-1311"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.4 for Aurora PostgreSQL 13.11 include the following:

**New features**
+ Introduced a new GUC auto\$1explain.hashes. When it is set to true (default: false), sql\$1hash and plan\$1hash are shown at the end of auto explain result. 
+ Introduced a new GUC apg\$1plan\$1mgmt.explain\$1hashes. When it is set to true (default: false), EXPLAIN result shows sql\$1hash and plan\$1hash even without hashes true option.
+ Introduced a new GUC apg\$1plan\$1mgmt.log\$1plan\$1enforcement\$1result. Depending on its value (default: none), plan enforcement results are written to Postgres log files.
+ Introduced a new plan hash calculation version to support partitioned tables. Users need to set apg\$1plan\$1mgmt.plan\$1hash\$1version to 3 and call apg\$1plan\$1mgmt.validate\$1plans('update\$1plan\$1hash') in each database with `apg_plan_mgmt` installed and entries in the plans table.
+  The `apg_plan_mgmt.copy_outline` function can take a new 5th argument, `force_update_target_plan_hash`. If it is set to true, the target plan hash will be updated even though the source plan isn't reproducible for the target sql\$1hash. 

**Additional improvements and enhancements**
+ Fixed an issue with JDBC prepared statements plan enforcement.
+ Fixed a plan enforcement issue when index names end with digits. 
+  The apg\$1plan\$1mgmt.copy\$1outline function now copies environment\$1variables. 
+  The minimum value of apg\$1plan\$1mgmt.plan\$1retention\$1period changes to 1 from 32. 
+  The query plan management can now save plans for queries in read-only transactions from the writer nodes. 
+  Fixed an issue in the apg\$1plan\$1mgmt.evolve\$1plan\$1baselines function. 
+  Fixed an issue that could cause unavailability when the apg\$1plan\$1mgmt is enabled. 

To learn how to install, upgrade, and use the `apg_plan_mgmt` extension, see [ Managing query execution plans for Aurora PostgreSQL](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraPostgreSQL.Optimize.html) in the *Amazon Aurora User Guide*.

## PostgreSQL 12 versions
<a name="auroraqpm-version12"></a>

**Topics**
+ [apg\$1plan\$1mgmt version 2.7 for Aurora PostgreSQL 12.22, December 27, 2024](#auroraqpm-version12-1222)
+ [apg\$1plan\$1mgmt version 2.7 for Aurora PostgreSQL 12.19, August 8, 2024](#auroraqpm-version12-1219)
+ [apg\$1plan\$1mgmt version 2.6 for Aurora PostgreSQL 12.18](#auroraqpm-version12-1218)
+ [apg\$1plan\$1mgmt version 2.6 for Aurora PostgreSQL 12.17](#auroraqpm-version12-1217)
+ [apg\$1plan\$1mgmt version 2.5 for Aurora PostgreSQL 12.16](#auroraqpm-version12-1216)

### apg\$1plan\$1mgmt version 2.7 for Aurora PostgreSQL 12.22, December 27, 2024
<a name="auroraqpm-version12-1222"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.7 for Aurora PostgreSQL 12.22 include the following:

**Additional improvements and enhancements**
+ Fixed an issue with plan capture on replica in query plan management where the shared memory array in the replica would become full.
+ Fixed an issue with query plan management background worker that caused plan retention period to not be enforced and last used date to not be updated.
+ Fixed an issue related to query plan management background worker.

### apg\$1plan\$1mgmt version 2.7 for Aurora PostgreSQL 12.19, August 8, 2024
<a name="auroraqpm-version12-1219"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.7 for Aurora PostgreSQL 12.19 include the following:

**New features**
+ You no longer need to update the `plan_hash_version`. After upgrading the database engine, QPM automatically enables new features. You don't need to take any action for new features to become available.

**Additional improvements and enhancements**
+ Fixed an issue with enforcement of QPM plans containing more than 64 partitioned tables.
+ Fixed an issue with enforcement of QPM plans containing the Append operator.
+ Fixed an issue with QPM validate\$1plans with update\$1plan\$1hash action.

### apg\$1plan\$1mgmt version 2.6 for Aurora PostgreSQL 12.18
<a name="auroraqpm-version12-1218"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.6 for Aurora PostgreSQL 12.18 include the following:

**Additional improvements and enhancements**
+ Fixed an issue related to plan capture.

### apg\$1plan\$1mgmt version 2.6 for Aurora PostgreSQL 12.17
<a name="auroraqpm-version12-1217"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.6 for Aurora PostgreSQL 12.17 include the following:

**New features**
+ Plan outlines will be updated to the latest format version as part of the `update_plan_hash` action for `apg_plan_mgmt.validate_plans` function.

### apg\$1plan\$1mgmt version 2.5 for Aurora PostgreSQL 12.16
<a name="auroraqpm-version12-1216"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.5 for Aurora PostgreSQL 12.16 include the following:

**New features**
+ To capture query plans from Replicas, you must update `apg_plan_mgmt` extension by calling ALTER EXTENSION apg\$1plan\$1mgmt UPDATE. 
+ You need to specify `apg_plan_mgmt.plan_capture_threshold` in order to not allow QPM to capture any query plans.

## Version 2.3 of the Aurora PostgreSQL apg\$1plan\$1mgmt extension
<a name="auroraqpm-version.23"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.3 includes the following:

**New extension features**
+ Support for a new function, the `apg_plan_mgmt.copy_outline` function. This function allows you to copy a plan hash and a plan outline from one SQL hash and plan hash to another. Use this function when you want to copy a plan that uses hints to other similar statements without using the in-line hint statement at every occurrence. If the update to the query results in an invalid plan, the function raises an error and rolls back the update. For more information, see [Function reference for Aurora PostgreSQL query plan management](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraPostgreSQL.Optimize.Functions.html#AuroraPostgreSQL.Optimize.Functions.copy_outline) in the *Amazon Aurora User Guide*. 

**Extension improvements**
+ The query plan management feature now saves plans for queries that are inside procedures and DO-blocks. For versions of `apg_plan_mgmt` older than version 2.3, this has been a limitation.

To learn how to install, upgrade, and use the `apg_plan_mgmt` extension, see [ Managing query execution plans for Aurora PostgreSQL](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraPostgreSQL.Optimize.html) in the *Amazon Aurora User Guide*.

## Version 2.1 of the Aurora PostgreSQL apg\$1plan\$1mgmt extension
<a name="auroraqpm-version.21"></a>

Improvements to the `apg_plan_mgmt` extension in version 2.1 for Aurora PostgreSQL 11.20 includes the following:

**New extension features in Aurora PostgreSQL 11.20**
+ Introduced a new GUC apg\$1plan\$1mgmt.log\$1plan\$1enforcement\$1result. Depending on its value (default: none), plan enforcement results are written to Postgres log files.

**Extension improvements in Aurora PostgreSQL 11.20**
+ Fixed an issue with JDBC prepared statements plan enforcement.

To learn how to install, upgrade, and use the `apg_plan_mgmt` extension, see [ Managing query execution plans for Aurora PostgreSQL](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraPostgreSQL.Optimize.html) in the *Amazon Aurora User Guide*.

## Version 2.0 of the Aurora PostgreSQL apg\$1plan\$1mgmt extension
<a name="auroraqpm-version.20"></a>

The `apg_plan_mgmt` extension changes for version 2.0 include the following:

**New extension features**

1. You can now manage all queries inside SQL functions, whether they have parameters or not.

1. You can now manage all queries inside PL/pgSQL functions, whether they have parameters or not.

1. You can now manage queries in generic plans, whether they have parameters or not. To learn more about generic plans versus custom plans, see the `PREPARE` statement in the [ PostgreSQL documentation](https://www.postgresql.org/docs/current/sql-prepare.html). 

1. You can now use query plan management to enforce the use of specific types of aggregate methods in query plans.

**Extension improvements**

1. You can now save plans with a size up to 8KB times the setting of the `max_worker_processes` parameter. Previously the maximum plan size was 8KB.

1. Fixed bugs for unnamed prepared statements such as those from JDBC.

1. Previously, when you tried to do `CREATE EXTENSION apg_plan_mgmt` when it is not loaded in the `shared_preload_libraries`, the PostgreSQL backend connection was dropped. Now, an error message prints and the connection is not dropped.

1. The default value of the `cardinality_error` in the `apg_plan_mgmt.plans table` is NULL, but it can be set to -1 during the `apg_plan_mgmt.evolve_plan_baselines` function. NULL is now used consistently.

1. Plans are now saved for queries that refer to temporary tables.

1. The default maximum number of plans is increased from 1000 to 10000.

1. The following pgss parameters are deprecated because the automatic plan capture mode should be used instead of those parameters.
   + `apg_plan_mgmt.pgss_min_calls`
   + `apg_plan_mgmt.pgss_min_mean_time_ms`
   + `apg_plan_mgmt.pgss_min_stddev_time_ms`
   + `apg_plan_mgmt.pgss_min_total_time_ms`

## Version 1.0.1 of the Aurora PostgreSQL apg\$1plan\$1mgmt extension
<a name="auroraqpm-version.101"></a>

The `apg_plan_mgmt` extension changes for version 1.0.1 include the following:

**New extension features**

1. The `validate_plans` function has a new `action` value called `update_plan_hash`. This action updates the `plan_hash` ID for plans that can't be reproduced exactly. The `update_plan_hash` value also allows you to fix a plan by rewriting the SQL. You can then register the good plan as an `Approved` plan for the original SQL. Following is an example of using the `update_plan_hash` action.

   ```
   UPDATE apg_plan_mgmt.plans SET plan_hash = new _plan_hash, plan_outline = good_plan_outline
      WHERE sql_hash = bad_plan_sql_hash AND plan_hash = bad_plan_plan_hash;
   SELECT apg_plan_mgmt.validate_plans(bad_plan_sql_hash, bad_plan_plan_hash, 'update_plan_hash');
   SELECT apg_plan_mgmt.reload();
   ```

1. A new `get_explain_stmt` function is available that generates the text of an `EXPLAIN` statement for the specified SQL statement. It includes the parameters `sql_hash`, `plan_hash` and `explain_options`. 

   The parameter `explain_options` can be any comma-separated list of valid `EXPLAIN` options, as shown following.

   ```
   analyze,verbose,buffers,hashes,format json
   ```

   If the parameter `explain_options` is NULL or an empty string, the `get_explain_stmt` function generates a simple `EXPLAIN` statement. 

   To create an `EXPLAIN` script for your workload or a portion of it, use the `\a` , `\t`, and `\o` options to redirect the output to a file. For example, you can create an `EXPLAIN` script for the top-ranked (top-K) statements by using the PostgreSQL `pg_stat_statements` view sorted by `total_time` in `DESC` order.

1. The precise location of the Gather parallel query operator is determined by costing, and may change slightly over time. To prevent these differences from invalidating the entire plan, query plan management now computes the same `plan_hash` even if the Gather operators move to different places in the plan tree.

1. Support is added for nonparameterized statements inside pl/pgsql functions.

1. Overhead is reduced when the `apg_plan_mgmt` extension is installed on multiple databases in the same cluster while two or more databases are being accessed concurrently. Also, this release fixed a bug in this area that caused plans to not be stored in shared memory.

**Extension improvements**

1. Improvements to the `evolve_plan_baselines` function.

   1. The `evolve_plan_baselines` function now computes a `cardinality_error` metric over all nodes in the plan. Using this metric, you can identify any plan where the cardinality estimation error is large, and the plan quality is more doubtful. Long-running statements with high `cardinality_error` values are high-priority candidates for query tuning.

   1. Reports generated by `evolve_plan_baselines` now include `sql_hash`, `plan_hash`, and the plan `status`.

   1. You can now allow `evolve_plan_baselines` to approve previously `Rejected` plans.

   1. The meaning of `speedup_factor` for `evolve_plan_baselines` is now always relative to the baseline plan. For example, a value of 1.1 now means 10 percent faster than the baseline plan. A value of 0.9 means 10 percent slower than the baseline plan. The comparison is made using running time alone instead of total time.

   1. The `evolve_plan_baselines` function now warms the cache in a new way. It does this by running the baseline plan, then running the baseline plan one more time, and then running the candidate plan once. Previously, `evolve_plan_baselines` ran the candidate plan twice. This approach added significantly to running time, especially for slow candidate plans. However, running the candidate plan twice is more reliable when the candidate plan uses an index that isn't used in the baseline plan.

1. Query plan management no longer saves plans that refer to system tables or views, temporary tables, or the query plan management's own tables.

1. Bug fixes include caching a plan immediately when saved and fixing a bug that caused the back end to terminate.