Skip to content

3 Architecture

Source chapter 3.1 for PostgreSQL 9.5.
Alpha 2Source pages: PDF 8-15Original PDF on GitHub

PDF page 8

3.1.1 New WAL format

XLogRecordBlockHeader structure is newly defined in src/include/access/xlogrecord.h. It is used in the output of the WAL file.

3.1.2 WAL compression

Specifying the parameter wal_compression to “on”, the WAL of Full Page Write (during the first update after CHECKPOINT completed) will be compressed and written. WAL pages are compressed by a PGLZ method, which is implemented in pglz_compress functions in the source code src/common/pg_lzcompress.c. Since the default value for the parameter wal_compression is “off”, this feature does not work under normal condition.

3.1.3 Added System Catalogs

With the addition of new features, the following system catalogs have been added.

Catalog NameDescription
pg_file_settingsParameter file and setting information
pg_policyRow level security policies for tables
pg_policiesRow level security applied table information
pg_replication_originUnverified
pg_replication_origin_statusUnverified
pg_stat_sslConnected user information which use SSL
pg_transformUnverified
Table 4 Added system Catalogs
pg_file_settings Catalog

Information of the loaded parameter file name (postgresql.conf, postgresql.auto.conf, etc) and parameters are stored in this catalog. The entity of this catalog is pg_show_all_file_settings function.

PDF page 9

Column NameData TypeDescription
sourcefiletextParameter filename (Full-path)
sourcelineintegerLine number in the parameter file
seqnointegerSerial number through the multiple files
nametextParameter name
settingtextParameter value
appliedbooleanTrue if the value can be applied successfully
errortextIf not null, an error message indicating why this entry could not be applied
Table 5 pg_file_settings Catalog

This catalog has the following features:

Every time search is performed for pg_file_settings catalogs, the parameter file is parsed.
This catalog also supports ‘include’ syntax in postgresql.conf file.
Example 1 Reload parameter file
postgres=# ALTER SYSTEM SET max_connections = 1000 ;
ALTER SYSTEM
postgres=# SELECT sourcefile, name, setting FROM pg_file_settings  WHERE
name = 'max_connections' ;
            sourcefile                |      name       | setting
------------------------------------------+-----------------+---------
 /usr/local/pgsql/data/postgresql.auto.conf | max_connections | 1000
(1 row)
pg_policy Catalog

This catalog provide the information about POLICY objects to be used in the Row Level Security feature. This catalog is created for each database.

PDF page 10

Column NameData TypeDescription
Table 6 pg_policy Catalog

polname name The name of the policy polrelid oid OID of the table to which the policy is applies polcmd char The command type to which the policy is applied:

SELECT = r
INSERT = a
UPDATE = w
DELETE = d
ALL = *

polroles oid[] Array of role OID to which the policy is applied polqual pg_node_tree Conditions checked in the USING clause polwithcheck pg_node_tree Conditions checked in the WITH CHECK clause

pg_policies Catalog

In this catalog, information on the table, to which the policy has been applied, is stored. This catalog created for each database.

Column NameData TypeDescription
schemanamenameSchema name of the policy applied table
tablenamenamePolicy applied table name
policynamenamePOLICY object name
rolesname[]Policy target roll
cmdtextPolicy target command
qualtextWHERE clause to check the policy
with_checktextWITH check clause
Table 7 pg_policies Catalog
pg_stat_ssl Catalog

This catalog provides the SSL information about sessions that are connected to the instance.

PDF page 11

Column NameData TypeDescriptionNote
pidintegerBackend process IDSame as pg_stat_activity.pid
sslbooleanIs SSL connection?
versiontextSSL version
ciphertextSSL cipher
bitsintegerSSL bit
compressionclientdnbooleanIs compressed?
textClient DN
Table 8 pg_stat_ssl Catalog
pg_transform Catalog

This catalog stores transform information that you created in the CREATE TRANSFORM statement. Details of the CREATE TRANSFORM statement and this catalog are unverified.

Column NameData TypeDescription
trftypeoidOID of the data type to which this transform is applied
trflangoidOID of the language to which this transform is applied
trffromsqlregprocOID of the input function which converts the data type
trftosqlregprocOID of the output function which converts the data type
Table 9 pg_transform Catalog

3.1.4 Modified Catalogs

The following System catalogs have been changed.

pg_settingsAdd pending_restart column
pg_tablesAdd rowsecurity column
pg_stat_statementsAdd some statistic columns (pg_stat_statements Contrib module)
pg_authidAdd rolbypassrls column, remove rolcatupdate column
Table 10 Modified catalogs

Catalog Name Changed pg_replication_slots Add active_pid column

pg_replication_slots Catalog

Process ID column of wal sender process has been added. This makes it possible of binding to pg_stat_replication catalog.

PDF page 12

ColumnData TypeDescription
active_pidintegerProcess ID of wal sender process
Table 11 Added column to pg_replication_slots Catalog

Following example shows join of pg_stat_replication and pg_replication_slots catalog, and display the correspondence of host name and the slot name of the slave instance. Since in some cases the slot is not used, LEFT OUTER JOIN clause is used.

Example 2 Join pg_stat_replication Catalog and pg_replication_slots Catalog
postgres=> SELECT r.client_hostname, r.pid, s.slot_name FROM
pg_stat_replication r
LEFT OUTER JOIN pg_replication_slots s ON r.pid = s.active_pid ;
 client_hostname |  pid  | slot_name
-----------------+-------+-----------
 dbslv1          | 12915 | slot_1
 dbslv2          | 12934 |
(2 rows)
pg_settings Catalog

Pending_restart column has been added. In spite of this change, the parameter which wait the restart can be checked. The value of this column becomes true when the parameter file is reloaded after changing the file, or after executing ALTER SYSTEM statement. This value is not changed by executing ALTER SYSTEM statement alone. Once pending_restart column becomes true, it will not be changed if the parameter value will be set to the original value.

Column NameData TypeDescription
pending_restartbooleanChanged in the configuration file and waiting a restart
Table 12 Added column to pg_settings Catalog
pg_stat_statements Catalog

In the pg_stat_statements catalog, that is created on registering a Contrib module pg_stat_statements, the columns which contain the execution time of maximum / minimum / average / standard derivation of the SQL statements.

PDF page 13

Column NameData TypeDescription
min_timedoubleprecisionMinimum time spent in the statement
max_timedoubleprecisionMaximum time spent in the statement
mean_timedoubleprecisionAverage time spent in the statement
stddev_timedoubleprecisionPopulation standard deviation of time spent in the statement
Table 13 Added columns to pg_stat_statements Catalog
pg_tables Catalog

Into the pg_tables catalog, which provides table information, rowsecurity column has been added. This column indicates whether Row Level Security feature is used or not. This column is true for the table of which has a setting of ENABLE ROW LEVEL SECURITY. It is false in the case of policy settings only.

Column NameData TypeDescription
rowsecuritybooleanTrue if Row Level Security is enabled on the table
Table 14 Added columns to pg_tables Catalog

3.1.5 Modified Contrib modules

In PostgreSQL 9.5, some Contrib module have been changed. Some commands widely used before have been moved from the Contrib module to PostgreSQL bin.

PDF page 14

Module NameChangedNote
hstore_plperlhstore_plpythonltree_plpythontsm_system_rowstsm_system_timeNewly added
pg_archivecleanupMove to PostgreSQL bin
pg_test_fsyncMove to PostgreSQL bin
pg_test_timingMove to PostgreSQL bin
pg_upgradeMove to PostgreSQL bin
pg_xlogdumppgbenchMove to PostgreSQL bin
test_parserMove to test/modulesChange directory
test_shm_mqMove to test/modulesChange directory
worker_spiMove to test/modulesChange directory
pg_stat_statementsAdded some featuresAdd some columns
pageinspectpgcryptopg_buffercacheAdded some features Add function Added some featuresAdd functions for BRIN index
Table 15 Changed in Contrib modules

3.1.6 Interface, API, Hook

Infrastructure for expanding the PostgreSQL has been developed.

Parallel processing Infrastructure

APIs for performing the parallel processing has been implemented. An explanation of the way to use dynamic shared memory and worker process has been described in the “src/backend/access/transam/README.parallel” file.

Custom Scan/Join Interface

Features to call hook functions to replace the execution plan have been provided. The following hooks have been added.

PDF page 15

HookDescriptionDefinition
set_rel_pathlist_hookset_join_pathlist_hookHook function for Custom Scan Hook function for Custom Joinsrc/include/optimizer/paths.h
Table 16 Added Hook

3.1.7 OOM Killer support

Environment variables to control Linux OOM killer have been added. However, in Linux, it needs root user privileges to write /proc/self/oom_score_adj file.

Variable nameDescription
PG_OOM_ADJUST_FILEPG_OOM_ADJUST_VALUEFile to set the weighting Value to set the weighting
Table 17 Environment variables for OOM Killer support

3.1.8 Archiving of last WAL segment

WAL file the slave instance is written partway will be output as “.partial” extension file after standby promotion.

Example 3 Archiving of last segment
$ pg_ctl -D data.slave1 promote
server promoting
$
$ psql -c 'SELECT pg_switch_xlog()'
 pg_switch_xlog
----------------
 0/146D2FA8
(1 row)
$ ls -1 arch.slave1
000000010000000000000014.partial
000000020000000000000014
00000002.history
$