Aurora PostgreSQL query plan management updates
The Amazon 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 in the Amazon Aurora User Guide.
Topics
- PostgreSQL 16 versions
- PostgreSQL 15 versions
- PostgreSQL 14 versions
- PostgreSQL 13 versions
- PostgreSQL 12 versions
- Version 2.3 of the Aurora PostgreSQL apg_plan_mgmt extension
- Version 2.1 of the Aurora PostgreSQL apg_plan_mgmt extension
- Version 2.0 of the Aurora PostgreSQL apg_plan_mgmt extension
- Version 1.0.1 of the Aurora PostgreSQL apg_plan_mgmt extension
PostgreSQL 16 versions
Topics
apg_plan_mgmt version 2.7 for Aurora PostgreSQL 16.3
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_plans with update_plan_hash action.
apg_plan_mgmt version 2.6 for Aurora PostgreSQL 16.2
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_plan_mgmt version 2.6 for Aurora PostgreSQL 16.1
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 forapg_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:
Set
apg_plan_mgmt.plan_hash_version
to 5.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
Topics
- apg_plan_mgmt version 2.7 for Aurora PostgreSQL 15.8, September 30, 2024
- apg_plan_mgmt version 2.7 for Aurora PostgreSQL 15.7, August 8, 2024
- apg_plan_mgmt version 2.6 for Aurora PostgreSQL 15.6
- apg_plan_mgmt version 2.6 for Aurora PostgreSQL 15.5
- apg_plan_mgmt version 2.5 for Aurora PostgreSQL 15.4
- apg_plan_mgmt version 2.4 for Aurora PostgreSQL 15.3
apg_plan_mgmt version 2.7 for Aurora PostgreSQL 15.8, September 30, 2024
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_plan_mgmt version 2.7 for Aurora PostgreSQL 15.7, August 8, 2024
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_plans with update_plan_hash action.
apg_plan_mgmt version 2.6 for Aurora PostgreSQL 15.6
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_plan_mgmt version 2.6 for Aurora PostgreSQL 15.5
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 forapg_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:
Set
apg_plan_mgmt.plan_hash_version
to 5.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_plan_mgmt version 2.5 for Aurora PostgreSQL 15.4
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_outline.
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_plan_mgmt 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_plan_mgmt version 2.4 for Aurora PostgreSQL 15.3
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_explain.hashes. When it is set to true (default: false), sql_hash and plan_hash are shown at the end of auto explain result.
-
Introduced a new GUC apg_plan_mgmt.explain_hashes. When it is set to true (default: false), EXPLAIN result shows sql_hash and plan_hash even without hashes true option.
-
Introduced a new GUC apg_plan_mgmt.log_plan_enforcement_result. 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_plan_mgmt.plan_hash_version to 3 and call apg_plan_mgmt.validate_plans('update_plan_hash') 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_hash.
Additional improvements and enhancements
-
Fixed an issue with JDBC prepared statements plan enforcement.
-
Improved parity regarding queryid between pg_stat_statements and apg_plan_mgmt.dba_plans.
-
Fixed a plan enforcement issue when index names end with digits.
-
The apg_plan_mgmt.copy_outline function now copies environment_variables.
-
The minimum value of apg_plan_mgmt.plan_retention_period 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_plan_mgmt.evolve_plan_baselines function.
-
Fixed an issue that could cause unavailability when the apg_plan_mgmt is enabled.
To learn how to install, upgrade, and use the apg_plan_mgmt
extension, see
Managing query execution plans for Aurora PostgreSQL in the Amazon Aurora User Guide.
PostgreSQL 14 versions
Topics
apg_plan_mgmt version 2.7 for Aurora PostgreSQL 14.12, August 8, 2024
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_plans with update_plan_hash action.
apg_plan_mgmt version 2.6 for Aurora PostgreSQL 14.11
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_plan_mgmt version 2.6 for Aurora PostgreSQL 14.10
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 forapg_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:
Set
apg_plan_mgmt.plan_hash_version
to 5.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_plan_mgmt version 2.5 for Aurora PostgreSQL 14.9
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_outline.
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_plan_mgmt 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_plan_mgmt version 2.4 for Aurora PostgreSQL 14.8
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_explain.hashes. When it is set to true (default: false), sql_hash and plan_hash are shown at the end of auto explain result.
-
Introduced a new GUC apg_plan_mgmt.explain_hashes. When it is set to true (default: false), EXPLAIN result shows sql_hash and plan_hash even without hashes true option.
-
Introduced a new GUC apg_plan_mgmt.log_plan_enforcement_result. 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_plan_mgmt.plan_hash_version to 3 and call apg_plan_mgmt.validate_plans('update_plan_hash') 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_hash.
Additional improvements and enhancements
-
Fixed an issue with JDBC prepared statements plan enforcement.
-
Improved parity regarding queryid between pg_stat_statements and apg_plan_mgmt.dba_plans.
-
Fixed a plan enforcement issue when index names end with digits.
-
The apg_plan_mgmt.copy_outline function now copies environment_variables.
-
The minimum value of apg_plan_mgmt.plan_retention_period 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_plan_mgmt.evolve_plan_baselines function.
-
Fixed an issue that could cause unavailability when the apg_plan_mgmt is enabled.
To learn how to install, upgrade, and use the apg_plan_mgmt
extension, see
Managing query execution plans for Aurora PostgreSQL in the Amazon Aurora User Guide.
PostgreSQL 13 versions
Topics
apg_plan_mgmt version 2.7 for Aurora PostgreSQL 13.15, August 8, 2024
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_plans with update_plan_hash action.
apg_plan_mgmt version 2.6 for Aurora PostgreSQL 13.14
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_plan_mgmt version 2.6 for Aurora PostgreSQL 13.13
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 forapg_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:
Set
apg_plan_mgmt.plan_hash_version
to 5.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_plan_mgmt version 2.5 for Aurora PostgreSQL 13.12
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_outline.
-
To capture query plans from Replicas, you must update
apg_plan_mgmt
extension by calling ALTER EXTENSION apg_plan_mgmt UPDATE. -
You need to specify
apg_plan_mgmt.plan_capture_threshold
in order to not allow QPM to capture any query plans.
apg_plan_mgmt version 2.4 for Aurora PostgreSQL 13.11
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_explain.hashes. When it is set to true (default: false), sql_hash and plan_hash are shown at the end of auto explain result.
-
Introduced a new GUC apg_plan_mgmt.explain_hashes. When it is set to true (default: false), EXPLAIN result shows sql_hash and plan_hash even without hashes true option.
-
Introduced a new GUC apg_plan_mgmt.log_plan_enforcement_result. 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_plan_mgmt.plan_hash_version to 3 and call apg_plan_mgmt.validate_plans('update_plan_hash') 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_hash.
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_plan_mgmt.copy_outline function now copies environment_variables.
-
The minimum value of apg_plan_mgmt.plan_retention_period 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_plan_mgmt.evolve_plan_baselines function.
-
Fixed an issue that could cause unavailability when the apg_plan_mgmt is enabled.
To learn how to install, upgrade, and use the apg_plan_mgmt
extension, see
Managing query execution plans for Aurora PostgreSQL in the Amazon Aurora User Guide.
PostgreSQL 12 versions
Topics
apg_plan_mgmt version 2.7 for Aurora PostgreSQL 12.19, August 8, 2024
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_plans with update_plan_hash action.
apg_plan_mgmt version 2.6 for Aurora PostgreSQL 12.18
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_plan_mgmt version 2.6 for Aurora PostgreSQL 12.17
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 forapg_plan_mgmt.validate_plans
function.
apg_plan_mgmt version 2.5 for Aurora PostgreSQL 12.16
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_plan_mgmt 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_plan_mgmt extension
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 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 in the Amazon Aurora User Guide.
Version 2.1 of the Aurora PostgreSQL apg_plan_mgmt extension
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_plan_mgmt.log_plan_enforcement_result. 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 in the Amazon Aurora User Guide.
Version 2.0 of the Aurora PostgreSQL apg_plan_mgmt extension
The apg_plan_mgmt
extension changes for version 2.0 include the
following:
New extension features
-
You can now manage all queries inside SQL functions, whether they have parameters or not.
-
You can now manage all queries inside PL/pgSQL functions, whether they have parameters or not.
-
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. -
You can now use query plan management to enforce the use of specific types of aggregate methods in query plans.
Extension improvements
-
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. -
Fixed bugs for unnamed prepared statements such as those from JDBC.
-
Previously, when you tried to do
CREATE EXTENSION apg_plan_mgmt
when it is not loaded in theshared_preload_libraries
, the PostgreSQL backend connection was dropped. Now, an error message prints and the connection is not dropped. -
The default value of the
cardinality_error
in theapg_plan_mgmt.plans table
is NULL, but it can be set to -1 during theapg_plan_mgmt.evolve_plan_baselines
function. NULL is now used consistently. -
Plans are now saved for queries that refer to temporary tables.
-
The default maximum number of plans is increased from 1000 to 10000.
-
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_plan_mgmt extension
The apg_plan_mgmt
extension changes for version 1.0.1 include the
following:
New extension features
-
The
validate_plans
function has a newaction
value calledupdate_plan_hash
. This action updates theplan_hash
ID for plans that can't be reproduced exactly. Theupdate_plan_hash
value also allows you to fix a plan by rewriting the SQL. You can then register the good plan as anApproved
plan for the original SQL. Following is an example of using theupdate_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(); -
A new
get_explain_stmt
function is available that generates the text of anEXPLAIN
statement for the specified SQL statement. It includes the parameterssql_hash
,plan_hash
andexplain_options
.The parameter
explain_options
can be any comma-separated list of validEXPLAIN
options, as shown following.analyze,verbose,buffers,hashes,format json
If the parameter
explain_options
is NULL or an empty string, theget_explain_stmt
function generates a simpleEXPLAIN
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 anEXPLAIN
script for the top-ranked (top-K) statements by using the PostgreSQLpg_stat_statements
view sorted bytotal_time
inDESC
order. -
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. -
Support is added for nonparameterized statements inside pl/pgsql functions.
-
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
-
Improvements to the
evolve_plan_baselines
function.-
The
evolve_plan_baselines
function now computes acardinality_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 highcardinality_error
values are high-priority candidates for query tuning. -
Reports generated by
evolve_plan_baselines
now includesql_hash
,plan_hash
, and the planstatus
. -
You can now allow
evolve_plan_baselines
to approve previouslyRejected
plans. -
The meaning of
speedup_factor
forevolve_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. -
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.
-
-
Query plan management no longer saves plans that refer to system tables or views, temporary tables, or the query plan management's own tables.
-
Bug fixes include caching a plan immediately when saved and fixing a bug that caused the back end to terminate.