3 Architecture
PDF page 14
3.1.1 Modified catalogs
The following catalogs have been changed.
| Catalog name | Description |
|---|---|
| pg_shmem_allocations | View the breakdown of shared memory. |
| pg_stat_progress_analyze | Tracking the progress of the ANALYZE statement. |
| pg_stat_progress_basebackup | Tracking the progress of the base backup. |
| pg_stat_slru | Tracking SLRU cache statistics. |
| Catalog name | Description |
|---|---|
| pg_pltemplate | Procedural language templates. |
| Catalog name | Description |
|---|---|
| sql_languages | SQL statement standards compliance levels, options, and dialects. |
| sql_packages | List of standard packages. |
| sql_sizing_profiles | List of defined size information. |
PDF page 15
| Catalog name | Added column | Data type | Description |
|---|---|---|---|
| pg_available_extension_versions | trusted | boolean | The extension can be installed by nonsuperusers. |
| pg_publication | pubviaroot | boolean | Convert partition updates to route tables. |
| pg_replication_slots | wal_status | text | WAL file status. |
| safe_wal_size | bigint | A number of bytes that can be written to WAL for the state “lost”. | |
| pg_stat_activity | leader_pid | integer | Leader PID for the parallel query. |
| pg_stat_{all|sys|user}_tables | n_ins_since_vacuum | bigint | The Number of tuples inserted since the last VACUUM. |
| pg_stat_wal_receiver | written_lsn | pg_lsn | The last WAL location for already received and written to disk, but not flushed. |
| flushed_lsn | pg_lsn | The last WAL location already received and flushed to disk. | |
| pg_statistic_ext | stxstattarget | integer | SET STATISTIC value. |
| pg_trigger | tgparentid | oid | OID of parent trigger. |
| Catalog name | Dropped column | Description |
|---|---|---|
| pg_stat_wal_receiver | received_lsn | Split into written_lsn and flushed_lsn. |
| Catalogname | Description |
|---|---|
| pg_locks | The value ‘speculative token’ output in the locktype column has changed to ‘spectoken’. |
| pg_stat_ssl | Process information other than client connection has been removed. |
| pg_stat_gssapi | Process information other than client connection has been removed. |
Catalog name Description
Among the modified system catalogs, the details of the major catalogs are described below.
PDF page 16
Pg_shmem_allocations catalog
The pg_shmem_allocations catalog allows you to see the breakdown in shared memory. However, it does not include the area of dynamic shared memory. Only users with the SUPERUSER attribute can see this catalog.
| Column name | Data type | Description |
|---|---|---|
| name | text | The name of the memory area, ’null’ is an unused area. |
| off | bigint | Offset from the start position. |
| size | bigint | Reserved bytes. |
| allocated_size | bigint | Reserved bytes including padding. |
Pg_stat_progress_analyze catalog
The pg_stat_progress_analyze catalog allows you to check the execution status of the ANALYZE statement. This catalog can be viewed by ordinary users, but ordinary users cannot see the status of other users’ command execution.
PDF page 17
| Column name | Data type | Description |
|---|---|---|
| pid | integer | Backend process ID. |
| datid | oid | OID of the connection database. |
| datname | name | Connection database name. |
| relid | oid | Table OID executing ANALYZE statement. |
| phase | text | Execution phase. |
| sample_blks_total | bigint | Total number of blocks sampled. |
| sample_blks_scanned | bigint | Number of sampled blocks. |
| ext_stats_total | bigint | Extended statistics. |
| ext_stats_computed | bigint | Number of extended statistics computed. |
| child_tables_total | bigint | Number of child tables. |
| child_tables_done | bigint | Number of child tables for ANALYZE are done. |
| current_child_table_relid | oid | ANALYZE executing child table OID. |
Pg_stat_progress_basebackup catalog
The pg_stat_progress_basebackup catalog allows you to check the status of the backups performed by tools such as the pg_basebackup command. This catalog can be viewed by non-superuser users, but only the ‘pid’ column can be viewed by non-connected users.
PDF page 18
| Column name | Data type | Description |
|---|---|---|
| pid | integer | WAL sender process ID. |
| phase | text | The string indicating the execution phase. |
| backup_total | bigint | Total backup size. |
| backup_streamed | bigint | Streaming data volume. |
| tablespaces_total | bigint | Number of total tablespaces. |
| tablespaces_streamed | bigint | Number of streaming tablespaces. |
Pg_stat_slru catalog
Pg_stat_slru catalog can check the usage status of the SLRU cache. Displays statistics on accesses to cached pages for each SLRU cache area.
| Column name | Data type | Description |
|---|---|---|
| name | text | SLRU name. |
| blks_zeroed | bigint | Number of blocks initialized to zero. |
| blks_hit | bigint | Number of blocks that hit the cache. |
| blks_read | bigint | Number of blocks read. |
| blks_written | bigint | Number of blocks written. |
| blks_exists | bigint | Number of blocks checked for existence in the cache. |
| flushes | bigint | Number of dirty blocks flushed. |
| truncates | bigint | Number of blocks truncated. |
| stats_reset | timestamp with time zone | Date and time when statistics were reset. |
PDF page 19
The counter values in this view will persist across instance reboots. Execute pg_stat_reset_slru function2 to reset the counter value.
3.1.2 Data types
The following data types have been added:
Regcollation
The regcollation type that indicates the Collation name has been added. A to_regcollation function has been added to convert from text type to regcollation type.
PDF page 20
Xid8
The xid8 type that indicates a 64-bit transaction ID has been added. Functions that use the xid8 type have been added. The functions that return the conventional 32-bit transaction ID are kept for compatibility. However, they may be removed in the future.
| function name | function name |
|---|---|
| txid_current | pg_current_xact_id |
| txid_current_if_assigned | pg_current_xact_id_if_assigned |
| txid_current_snapshot | pg_current_snapshot |
| txid_snapshot_xip | pg_snapshot_xip |
| txid_snapshot_xmax | pg_snapshot_xmax |
| txid_snapshot_xmin | pg_snapshot_xmin |
| txid_visible_in_snapshot | pg_visible_in_snapshot |
| txid_status | pg_xact_status |
Pg_snapshot
The pg_snapshot type stores information about the transaction ID visibility (xmin, xmax, xip_list) at a specific point in time.
Other abstract data types
In addition, the following abstract data types have been added.
| Data type name | Description |
|---|---|
| anycompatible | The function accepts any data type and is automatically promoted. |
| anycompatiblearray | The function accepts any array type and is automatically promoted. |
| anycompatiblenonarray | The function accepts an non-array type and is automatically promoted. |
| anycompatiblerange | The function accepts any range type and is automatically promoted. |
| table_am_handler | Table access method handler. |
3.1.3 Disk-based hash aggregation
A hash table may be created in memory when executing a GROUP BY or DISTINCT clause. PostgreSQL 13 performs storage-based hash aggregation if the hash table cannot be stored in work memory. In previous versions, work memory was created on the assumption that it could be stored in
PDF page 21
memory, which could lead to unexpected increases in memory usage.
3.1.4 Incremental sort
Incremental sorting is a way to reduce the resources used for multi-column sorting. It is used when another column needs to be sorted in addition to the already sorted column. This feature can be controlled by the enable_incremental_sort parameter. The default value is ‘on’.
PDF page 22
3.1.5 Backup manifests
Consistency checks can now be executed on base backups created with the pg_basebackup command, etc. The size and checksum are calculated for each file in the database cluster.
Checksum
The checksum calculation method can be selected from SHA224, SHA256, SHA384, SHA512, and CRC32C. CRC32C is the default value.
Manifest file
The backup manifest is stored as backup_manifest in the backup directory. It is a file in JSON format.
PDF page 23
Check consistency
The pg_verifybackup command is provided to recheck the integrity of the obtained backup. Specify the backup destination directory name to the pg_verifybackup command3.
3 See 3.4.6 pg_verifybackup
PDF page 24
3.1.6 Partitioned table
The following features have been added to the partitioned table.
Logical replication support
The partitioned tables can now be added to PUBLICATION in a logical replication environment. In the previous version, the CREATE PUBLICATION statement in the example below failed. In order for replication to succeed, a table with the same structure is required on the SUBSCRIPTION side.
PDF page 25
By default, PUBLICATION sends updates to the partition to SUBSCRIPTION without converting them to updates to the partition table. When replicating to a non-partitioned table on the SUBSCRIPTION side, set the PUBLICATION attribute publish_via_partition_root to ‘off’.
BEFORE INSERT trigger
ROW level BEFORE INSERT triggers can now be set. However, a tuple is not possible to change the partition to be stored.
PDF page 26
Allow partition wise join in more case
Partition-wise join can now be performed even if the partition structures are not the same. This feature does not work with hash partitioned tables.
Partitioned column using the entire table
It is now possible to specify an entire column to the definition of the partitioning columns.
PDF page 27
3.1.7 Log output for Autovacuum
WAL statistics are now output to the automatic VACUUM log.
3.1.8 Wait events
Wait events that are output to the wait_event column of the pg_stat_activity catalog had the following changes.
PDF page 28
| Wait event name | Description |
|---|---|
| BackupWaitWalArchive | Waiting for archive creation. |
| RecoveryConflictSnapshot | Waiting for recovery conflict resolution during VACUUM cleanup. |
| RecoveryConflictTablespace | Waiting for resolution of recovery conflict when deleting table space. |
| RecoveryPause | Waiting for the promotion of standby instance. |
| VacuumDelay | Cost-based VACUUM delay. |
| ProcSignalBarrier | Waiting for a barrier event to be processed by all backends. |
| Wait event name (PostgreSQL 12) | Wait event name (PostgreSQL 13) |
|---|---|
| AsyncCtlLock | NotifySLRU |
| AsyncQueueLock | NotifyQueue |
| CLogControlLock | XactSLRU |
| ClogGroupUpdate | XactGroupUpdate |
| CommitTsControlLock | CommitTsSLRU |
| Hash/Batch/Allocating | HashBatchAllocate |
| Hash/Batch/Electing | HashBatchElect |
| Hash/Batch/Loading | HashBatchLoad |
| Hash/Build/Allocating | HashBuildAllocate |
| Hash/Build/Electing | HashBuildElect |
| Hash/Build/HashingInner | HashBuildHashInner |
| Hash/Build/HashingOuter | HashBuildHashOuter |
| Hash/GrowBatches/Allocating | HashGrowBatchesAllocate |
| Hash/GrowBatches/Deciding | HashGrowBatchesDecide |
| Hash/GrowBatches/Electing | HashGrowBatchesElect |
| Hash/GrowBatches/Finishing | HashGrowBatchesFinish |
| Hash/GrowBatches/Repartitioning | HashGrowBatchesRepartition |
| Hash/GrowBuckets/Allocating | HashGrowBucketsAllocate |
| Hash/GrowBuckets/Electing | HashGrowBucketsElect |
| Hash/GrowBuckets/Reinserting | HashGrowBucketsReinsert |
| MultiXactOffsetControlLock | MultiXactOffsetSLRU |
| MultiXactMemberControlLock | MultiXactMemberSLRU |
| OldSerXidLock | SerialSLRU |
| RecoveryWalAll | RecoveryWalStream |
| RecoveryWalStream | RecoveryRetrieveRetryInterval |
| SerializablePredicateLockListLock | SerializablePredicateList |
| SubtransControlLock | SubtransSLRU |
| speculative token | spectoken |
PDF page 29
There are many event name changes other than the above table, such as deleting ‘Lock’ from the end of the event name.
3.1.9 libpq connection string
The following libpq connection strings have been added/changed.
Channel_binding parameter
The channel_binding parameter has been added to the client connection string to control channel binding. The values that can be specified are as follows.
| Value | Description |
|---|---|
| require | Required. |
| prefer | Client selection. |
| disable | Disable. |
‘Prefer’ is the default value when SSL is enabled. ‘Disable’ is the default value if SSL is disabled. The environment variable PGCHANNELBINDING can specify the same value as this parameter.
Sslkey parameter
ASN.1 DER format files can now be specified for the sslkey parameter.
Ssl_min_protocol_version, ssl_max_protocol_version parameter
Specify the minimum version (ssl_min_protocol_version) and maximum version (ssl_max_protocol_version) of the SSL / TLS protocol. Possible values are TLSv1, TLSv1.1, TLSv1.2, and TLSv1.3. The default value of ssl_min_protocol_version is TLSv1.2. if the value of ssl_max_protocol_version is not specified, the backend value is used. It is also possible to use the environment variables PGSSLMINPROTOCOLVERSION and PGSSLMAXPROTOCOLVERSION
PDF page 30
instead of using parameters.
Sslpassword parameter
Specify the password of the private key specified by the sslkey parameter.
3.1.10 libpq functions
BufferUsageAccumDiff
TupleHashTableHash
LookupTupleHashEntryHash
PQsetSSLKeyPassHook_OpenSSL
LogicalTapeSetExtend
3.1.11 Hook
The following hook functions have been provided.
TLS initialization hook
The TLS initialization hook was provided. Specify the callback function in openssl_tls_init_hook.
TRUNCATE hook
The hook is executed to allow mandatory access control (MAC) for the TRUNCATE statement. Contrib module sepgsql can control access to the TRUNCATE statement.
3.1.12 Column trigger
In a logical replication environment, column triggers are now executed on the subscription side.
3.1.13 Local connection key
Conventionally, the key information of the shared memory used by the instance was determined based on the connection waiting port number (parameter ‘port’). PostgreSQL 13 now uses the i-node number of the database cluster.
PDF page 31
3.1.14 Trusted Extension
The ’trusted’ attribute described in the extension control file ({extension}.control) file has been added. The default value for this attribute is ‘off’. Extensions with this attribute value set to ‘on’ can execute the CREATE EXTENSION statement even if the user does not have the SUPERUSER attribute. Users must have CREATE privilege on the database.
PDF page 32
PDF page 33
3.1.15 Replication slot
If the parameter primary_slot_name is not specified on the standby instance in a streaming replication environment, a temporary replication slot can be created on the primary instance. The standby instance parameter wal_receiver_create_temp_slot must be ‘on’ (default ‘off’).
3.1.16 Text search
Languages for text search have been increased. In PostgreSQL 12, there were 22 languages, but in PostgreSQL 13, Greek has been added.
PDF page 34