7 Contrib Modules
PDF page 105
This section describes new features related to the Contrib module.
3.5.1 Auto_explain
The following parameters have been added to the auto_explain module.
Parameter log_extension_options
The auto_explain.log_extension_options parameter has been added. This parameter specifies the string to be passed to the EXPLAIN statement in additional modules such as pg_overexplain.
Parameter log_io
The parameter auto_explain.log_io has been added. The default value is “off”. If this parameter is set to “on”, I/O statistics for executed SQL statements will be logged. This feature is effective only when the parameter auto_explain.log_analyze is set to “on”. [61c36a3]
Parameter log_extension_options
This includes additional options from external modules such as the pg_overexplain module and the pg_plan_adice module in the log.
PDF page 106
3.5.2 Basic_archive
The system no longer checks for the existence of the directory specified by the basic_archive.archive_directory parameter at startup. This change will be backported to PostgreSQL 15 and later. [cc774c5]
3.5.3 File_fdw
The “header” option, which specifies the number of header records in the data file, has been added. [26cb14a]
PDF page 107
3.5.4 Injection_points
The following new features have been added to the injection_points module.
Function injection_points_attach
The injection_points_attach function has been updated to include additional arguments. [16a2f70]
Function injection_points_list
The injection_points_list function, which returns a list of injection points, has been added. [4eca711]
Removed Functions
The following functions related to statistics information have been removed. [d52c24b]
PDF page 108
injection_points_stats_numcalls
injection_points_stats_drop
injection_points_stats_fixed
3.5.5 Pg_buffercache
The following new features have been implemented in the pg_buffercache module.
Add Views
The following views have been added. [4b203d4]
| View name | Description |
|---|---|
| pg_buffercache_os_pages | Mapping between the buffer pool and OS pages |
| pg_buffercache_numa | Mapping of the buffer pool and NUMA nodes |
Add Functions
The following functions have been added. [9ccc049, 4b203d4]
| Function name | Description |
|---|---|
| pg_buffercache_os_pages | Provides a mapping between the buffer pool and OS pages |
| pg_buffercache_mark_dirty | Sets the specified buffer to the dirty state |
| pg_buffercache_mark_dirty_relation | Sets the buffers for the specified relation in the buffer pool to the dirty state |
pg_buffercache_mark_dirty_all Sets all buffers in the buffer pool to the dirty state
PDF page 109
3.5.6 Pg_plan_advice
The new Contrib module pg_plan_advice has been added to PostgreSQL 19. This module provides features for changing execution plans and verifying the modified execution plans. [5883ff3, 6455e55, 26255a3]
Basic Usage
To use this module, follow the steps below. 1. Specify pg_plan_advice in the LOAD statement or in the shared_preload_libraries parameter. 2. Verify the execution plan using an EXPLAIN statement with the PLAN_ADICE option. 3. Information for changing the execution plan is output in the “Generated Plan Advice:” section. 4. Specify information regarding changes to the execution plan in the pg_plan_advice.advice parameter. 5. The execution plan will be changed. In the following example, the join order of tables data1 and data2 is changed to verify that the execution plan changes.
PDF page 110
PDF page 111
| Setting value | Description |
|---|---|
| SEQ_SCAN(target) | Use the sequential scan (Seq Scan) |
| INDEX_SCAN(target) | Use the specified index |
| JOIN_ORDER(item item…) | Specify the join order |
| HASH_JOIN(target) | Execute the hash join |
| NESTED_LOOP_PLAN(target) | Execute the nested loop join |
| GATHER(item) | Specify the parallel query |
| NO_GATHER(item) | Do not use a parallel query |
| DO_NOT_SCAN(item) | Stop scanning the specified relation |
PDF page 112
Parameters
The pg_plan_advice module provides the following custom parameters.
| Parameter name | Description | Default value |
|---|---|---|
| advice | Advice on changing the execution plan | '' |
| always_explain_supplied_advice | Always include output indicating which child has had its execution plan changed in the results of the EXPLAIN statement | on |
| always_store_advice_details | Whether to output feedback for prepared statements | off |
| feedback_warnings | Whether to issue a warning if the advice was not successfully applied | off |
| trace_mask | Whether to output debug traces | off |
If the always_explain_supplied_advice parameter is set to “on” (the default value), the EXPLAIN statement will always output information about any changes to the execution plan (under the heading “Supplied Plan Advice:”). If this parameter is set to “off”, specifying the PLAN_ADVICE option in the EXPLAIN statement is required to output information about changes to the execution plan.
3.5.7 Pg_stash_advice
The new Contrib module pg_stash_advice has been added to PostgreSQL 19. The pg_stash_advice module applies execution plan advice to query IDs. By default, the generated advice is stored in memory and is not persisted. To persist the advice stash data, set the pg_stash_advice.persist parameter to “true”. The persisted data is created as the file pg_stash_advice.tsv in the database cluster. [e8ec19a, c10edb1]
| Function name | Description | Note |
|---|---|---|
| pg_create_advice_stash | Creating the Advice Stash | |
| pg_drop_advice_stash | Dropping the Advice Stash | |
| pg_set_stashed_advice | Setting advice for a query | |
| pg_get_advice_stashes | List of Advice Stashes | |
| pg_get_advice_stash_contents | Viewing the contents of the Advice Stash |
PDF page 113
The following parameters are defined in this module.
| Parameter name | Description | Default value |
|---|---|---|
| pg_stash_advice.persist | Whether to persist advice | false |
| pg_stash_advice.stash_name | Name of the active advice stash | '' |
| pg_stash_advice.persist_interval | Persistence check interval | 30s |
Preparation
Set the shared_preload_libraries parameter to pg_stash_advice. Set the compute_query_id parameter to “auto” (default value) or “on”. Next, enable the module using the CREATE EXTENSION statement.
PDF page 114
PDF page 115
3.5.8 Pg_stat_statements
The following new features have been added to the pg_stat_statements module.
PDF page 116
Changes in the pg_stat_statements view
The following columns have been added to the pg_stat_statements view. [3357471]
| Column name | Data type | Description |
|---|---|---|
| generic_plan_calls | bigint | Number of executions of the generic execution plan |
| custom_plan_calls | bigint | Number of executions of the custom execution plan |
Constancy of FETCH Statements
The number of rows specified in the FETCH statement is now treated as the constant and assigned the single query ID. [bee23ea]
PDF page 117
3.5.9 Postgres_fdw
The following features have been added to the postgres_fdw module.
Option restore_stats
The Foreign Data Wrapper now supports importing remote statistics via the callback. The postgres_fdw module implements this callback, and the restore_stats option can be specified for both the FOREIGN SERVER and the FOREIGN TABLE. [28972b6]
PDF page 118
Pushdown of ARRAY Operations
When using a generic plan, the ANY clause in the PREPARE statement can now be pushed down. [62c3b4c]
PDF page 119
Transaction State Propagation
The status of local READ ONLY and DEFERRABLE transactions is now pushed down to remote connections. [de28140]
3.5.10 Miscellaneous
In addition to what was described above, the following test extension modules have been added to the src/test/modules directory. [31280d9, e0e4c13]
| Module name | Description | Note |
|---|---|---|
| test_binaryheaptest_bitmapsettest_checksums | Binary heap testing Bitmapset testing Checksum behavior testing | |
| test_cplusplusext | C++ header compilation testing | |
| test_custom_stats | Fixed- and variable-size custom statistics testing | |
| test_custom_types | Custom type testing | |
| test_int128 | 128-bit int type testing | |
| test_lwlock_tranchestest_plan_advicetest_saslpreptest_shmem | LWLock Tranche testing pg_plan_advice module testing SASLprep implementation testing Shared memory testing |