3 Architecture
PDF page 18
Describes the improved architecture and features in PostgreSQL 18.
3.1.1 Modified System catalogs
The following catalogs and views have been changed. [12227a1, 32d3ed8, f0d1127, 559efce, 17cc5f6, 7054186, e7a9496, 02a8d0c, a0f1fce, ca87c41, f92c854, 30a6ed0, 75eb976, a051e71, 83ea6c5, bb8dff9, ac0e331, 2421e9a, 99f8f3f, 60f566b, 89f908a, 73eba50, 8cc139b, 0d6c477]
| View name | Description |
|---|---|
| pg_aios | The pg_aios view lists all asynchronous I/O handles. |
| pg_shmem_allocations_numa | Shows how shared memory allocations in the server’s main shared memory segment are distributed across NUMA nodes. |
| View name | Add column | Data type | Description |
|---|---|---|---|
| pg_backend_memory_contexts | type | text | Context type |
| path | integer[] | Array showing context hierarchy | |
| pg_class | relallfrozen | integer | Number of pages marked as all frozen |
| pg_constraint | conenforced | boolean | Is the constraint specified as ENFORCED? |
| conperiod | boolean | Specify WITHOUT OVERLAPS or PERIOD | |
| pg_publication | pubgencols | char | Replicate the values of the generated columns? |
| pg_replication_slots | two_phase_at | pg_lsn | Address from which the decoding of prepared transactions is enabled |
| pg_stat_{all|user|sys}_tables | total_vacuum_ti | double | Total time for VACUUM execution |
| me | precision | ||
| total_autovacuu | double | Total time for automatic VACUUM | |
| m_time | precision | execution | |
| total_analyze_ti | double | Total time of ANALYZE execution | |
| me | precision | ||
| total_autoanalyze | double | Total time for automatic ANALYZE | |
| _time | precision | execution | |
| pg_stat_checkpointer | num_done | bigint | Number of checkpoints completed |
| slru_written | bigint | Number of SLRU buffers written during checkpoint | |
| pg_stat_database | parallel_workers_to_launch | bigint | Number of parallel workers attempted to be activated |
| parallel_workerslaunched_ | bigint | Number of parallel workers activated | |
| pg_stat_io | read_bytes | numeric | Number of bytes read |
| write_bytes | numeric | Number of bytes write | |
| extend_bytes | numeric | Number of extended bytes | |
| pg_stat_progress_analyze | delay_time | double precision | Sleep time due to cost-based delay |
| pg_stat_progress_vacuum | delay_time | double precision | Sleep time due to cost-based delay |
| pg_stat_subscription_stats | confl_update_origin_differs | bigint | Number of tuples modified by other sources during execution of the UPDATE statement |
| confl_update_exists | bigint | Number of tuples that violated the unique constraint during execution of the UPDATE statement | |
| confl_update_missing | bigint | Number of tuples not found to be changed during execution of the UPDATE statement | |
| confl_delete_origin_differs | bigint | Number of tuples modified by other sources during execution of the DELETE statement | |
| confl_delete_missing | bigint | Number of tuples not found for deletion during execution of the DELETE statement | |
| confl_multiple_unique_conflicts | bigint | Number of tuples that violated the unique constraint when executing a multi-tuple INSERT statement | |
| confl_insert_exists | bigint | Number of tuples that violated the unique constraint when the INSERT statement was executed |
PDF page 19
PDF page 20
| View name | Remove column | Description |
|---|---|---|
| pg_backend_memory_contexts | parent | Due to the addition of the PATH column, it is no longer needed. |
| pg_attribute | attcacheoff | No longer needed due to changes in cache structure |
| pg_stat_wal | wal_write | For integration into pg_stat_io view |
| wal_sync | For integration into pg_stat_io view | |
| wal_write_time | For integration into pg_stat_io view | |
| wal_sync_time | For integration into pg_stat_io view | |
| pg_stat_io | op_bytes | Because it was a fixed value |
| View name | Column name | Description |
|---|---|---|
| table_constraints | enforced | Outputs YES or NO depending on column setting (previously only YES) |
| View name | Description |
|---|---|
| pg_aggregate | Includes max/min functions for user-defined types |
| pg_attribute | Outputs ‘v’ indicating virtual column in attgenerated column |
| pg_class | Outputs information on TOAST table in pg_index catalog |
| pg_constraint | Includes information on NOT NULL constraints for columns |
| pg_default_acl | L (Large Object) output in defaclobjtype column |
| pg_proc | Includes max/min functions for user-defined types |
| pg_replication_slots | Outputs idle_timeout in invalidation_reason column |
| pg_stat_io | WAL information added |
PDF page 21
Pg_aios view
The pg_aios view outputs the status of the currently used asynchronous I/O handle. [60f566b]
| Column name | Data type | Description |
|---|---|---|
| pid | integer | Server process ID performing I/O |
| io_id | integer | I/O handle ID |
| io_generation | bigint | I/O handle generation |
| state | text | I/O handle status |
| operation | text | I/O handle operations |
| off | bigint | I/O operation offset |
| length | bigint | I/O operation length |
| target | text | I/O execution target |
| handle_data_len | smallint | I/O operation data length |
| raw_result | integer | Low-level I/O results |
| result | text | High-level I/O results |
| target_desc | text | I/O target description |
| f_sync | boolean | I/O execution flags |
| f_localmem | boolean | Local memory flag |
| f_buffered | boolean | Flag indicating buffer I/O |
Pg_shmem_allocations_numa view
This view shows how shared memory segments are distributed among NUMA nodes. [8cc139b]
| Column name | Data type | Description |
|---|---|---|
| name | text | Memory area name |
| numa_node | integer | NUMA node number |
| size | bigint | Memory size |
PDF page 22
NOT NULL constraint
NOT NULL constraints on a table columns are now included in the pg_constraint catalog. The constraint name is automatically generated from the table and column names. The value of the contype column of the NOT NULL constraint is specified as ’n’. [14e87ff]
PDF page 23
Pg_stat_{all|user|sys}_tables view
VACUUM and ANALYZE execution times have been added to the pg_stat_{all|user|sys}_tables view. The manually executed and automatically executed cases are cumulated, respectively. [30a6ed0]
3.1.2 Logical Replication Enhancements
The following new features have been implemented for logical replication
Log output when conflicts occur
Information about conflicts that occur when updating against the standby database are now output to the log. The reason for the conflict is output in the format “conflict={reason}”. The parameter track_commit_timestamp must be set to ‘on’ on the subscriber side (default value ‘off’) to detect the conflict reasons update_differ and delete_differ. [9758174, 73eba50]
PDF page 24
| Output text | Description (DETAIL log) | Replication |
|---|---|---|
| insert_exists | INSERT statement was executed but a tuple with the same key already exists (Key already exists in unique index) | Stop |
| update_differ | UPDATE statement target tuple was updated by another origin (Updating the row that was modified locally) | Continue |
| update_exists | UPDATE statement was executed but a tuple with the same key exists (Key already exists in unique index) | Stop |
| update_missing | UPDATE statement was executed but the target tuple does not exist (Could not find the row to be updated) | Continue |
| delete_differ | DELETE statement was executed but the target tuple was updated by another origin (Updating the row that was modified locally) | Continue |
| delete_missing | DELETE statement executed but target tuple does not exist (Could not find the row to be deleted) | Continue |
| multiple_unique_conflicts | Multiple tuples violate unique constraints (Key already exists in unique index) | Stop |
PDF page 25
Propagation of Generated Columns
The option PUBLISH_GENERATED_COLUMNS has been added to the CREATE PUBLICATION statement to determine whether the values of generated columns (GENERATED ALWAYS AS STORED specified columns) are to be replicated. The default value for this option is ‘none’, which means that the values of the generated columns will not be propagated. To propagate generated columns, specify ‘stored’ for this option. The value of the specified option is stored in the pubgencols_type column of the pg_publication catalog. [7054186, 745217a, 7054186, e65dbc9, 117f9f3]
PDF page 26
3.1.3 Optimizer Statistics Management
Functions to set and clear optimizer statistics for tables and columns are now provided. Options have been added to the pg_dump, pg_dumpall, and pg_upgrade commands to use this function to migrate statistics. See “3.4 Utilities” for additional command options.
Pg_restore_relation_stats function
The pg_restore_relation_stats function sets the optimizer statistics for a table. It returns false in case of minor errors. [d32d146]
Syntax 1 - Pg_restore_relatoin_stats function
Pg_clear_relation_stats function
The function pg_clear_relation_stats clears the optimizer statistics for the specified table. Executing this function resets the corresponding column in the pg_class catalog. [e839c8e, 650ab8a]
Syntax 2 - Pg_clear_relation_stats function
PDF page 27
Pg_restore_attribute_stats function
The function pg_restore_attribute_stats sets the column optimizer statistics. It returns false in case of minor errors. [d32d146]
Syntax 3 - Pg_restore_attribute_stats function
PDF page 28
Pg_clear_attribute_stats function
The function pg_clear_attribute_stats clears the optimizer statistics for the specified column. Executing this function resets the corresponding column in the pg_stats catalog. [ce207d2, 650ab8a]
Syntax 4 - Pg_clear_attribute_stats function
3.1.4 Roles and Permissions
The role pg_signal_autovacuum_worker has been added as a predefined role. This role allows signaling to the Autovacuum worker process. [ccd3802]
3.1.5 I/O Processing
PostgreSQL 18 adds large enhancements to the Storage I/O.
Streaming I/O coverage enhancement
Streaming I/O, introduced in PostgreSQL 17, is now more widely applicable. Streaming I/O is used in the following cases
VACUUM statement for a table [9256822, c3e775e, 9256822, c3e775e]
CREATE DATABASE STRATEGY=WAL_LOG statement [8720a15]
VACUUM for B-Tree index [c5c239e]
VACUUM for GiST index [69273b8]
VACUUM for SP-GiST index [e215166]
Amcheck module [043799f]
Autoprewarm module [d9c7911]
PDF page 29
Providing Asynchronous I/O
The infrastructure for using asynchronous I/O is now in place. The parameter io_method has been added to specify the method used for asynchronous I/O. The default value of this parameter is ‘worker’, which performs asynchronous I/O by an I/O worker process; the number of I/O worker processes started is determined by the parameter io_workers (default value 3). If using Linux’s io_uring, specify io_uring for this parameter. [da72269, 55b454d, 247ce06, c325a76]
| Value | Description | Note |
|---|---|---|
| worker | Asynchronous I/O is executed by the io worker process. | Default |
| sync | Synchronous I/O is executed. This is the same behavior as in the previous version. | |
| io_uring | Use io_uring for asynchronous I/O. |
Prefetch support
Prefetching is now possible with PostgreSQL running on macOS. [6654bb9]
3.1.6 Locale Provider
The locale PG_UNICODE_FAST has been added to the builtin locale provider. This locale uses code point sort order and conforms to Unicode’s full case mapping. However, conversions may cause changes in the number of characters, such as “ß” being lowercased to “ss”. [d3d0983, 286a365]
PDF page 30
3.1.7 OAUTH SASL
OAUTHBearer/SASL can now be used for database user authentication. To use OAUTHBearer/SASL authentication, specify ‘oauth’ in the pg_hba.conf authentication method. To use this authentication, the client module uses the libcurl library, so a binary with –with-libcurl to the ‘configure’ command is required. The parameter oauth_validator_libraries specifies the validator libraries. If this parameter is not specified, authentication by the oauth authentication method will be failed. [b3f0be7]
3.1.8 Faster hash joins
Deform processing during hash join execution has been optimized. [adf97c1]
PDF page 31
3.1.9 Libpq
The following APIs have been added and enhanced.
Connection string
The minimum / maximum protocol version and SSL connection log file name have been added to the connection string. Corresponding environment variables have also been added. [285613c, 2da74d8]
| Connect string | Environment variables | Description |
|---|---|---|
| max_protocol_version | PGMAXPROTOCOLVERSION | Maximum version |
| min_protocol_version | PGMINPROTOCOLVERSION | Minimum version |
| sslkeylogfile | - | SSL key log file |
PDF page 32
Other API
| API Name | Description |
|---|---|
| PQfullProtocolVersion | Return protocol version including minor version |
3.1.10 Access Method
The following enhancements have been added to the index access methods. [56fead4, af4002b, ce62f2f, af4002b]
| Element name | Description |
|---|---|
| amgettreeheight | Calculates the height of the index tree |
| amconsistentequality | Consistent equivalence semantics. Split old version of amcancrosscompare. Has consistent ordering semantics. Split out old version of amcancrosscompare. |
| amcanhash | Support hashing |
3.1.11 NUMA
The basic NUMA environment-aware API, SQL functions and pg_shmem_allocations_numa view have been added. The –with-libnuma option to the ‘configure’ command is required to enable this feature. [65c298f, 8cc139b]
| API names | Description |
|---|---|
| pg_numa_init | Initialize NUMA environment |
| pg_numa_get_max_node | Get maximum number of nodes |
| pg_numa_query_pages | Identify NUMA nodes in individual memory pages |
PDF page 33
3.1.12 Accelerated numerical calculations
Acceleration of the following basic calculations and CRC32C functions are implemented.
3.1.13 Scope of Use of Unique Key Constraints
Previously, only B-Tree indexes could be used for foreign keys, materialized views, and partition keys, but now other index access methods can be used to create indexes as long as they are unique. [bfe21b7, 9d6db8b, f278e1f]
3.1.14 Hook
The following hooks for the EXPLAIN statement have been added. [fd02bf7, 50ba65e]
Hook explore_per_plan_hook for EXPLAIN statement
Hook explain_per_node_hook for per-node execution
Hook for option validation, explore_validate_options_hook