This is a newly added Contrib module. This module defines the pg_old_snapshot_time_mapping function. When the parameter old_snapshot_threshold is set to something other than -1, the mapping between XIDs and timestamps can be displayed.
Additional information “last cleanup num del pages” is now output.
Example 95Output of bt_metap function
postgres=# SELECT * FROM bt_metap('idx1_data1') ;
-[ RECORD 1 ]-------------+-------
magic | 340322
version | 4
root | 290
level | 2
fastroot | 290
fastlevel | 2
last_cleanup_num_delpages | 0
last_cleanup_num_tuples | -1
allequalimage | t
PDF page 80
3.5.7 Passwordcheck
The reason is now output in the output of the check using the Cracklib library.
Example 96Password check
postgres=# CREATE USER demo PASSWORD 'password123' ;
ERROR: password is easily cracked
postgres=# \! tail -3 data/log/postgresql-2020-10-01_151319.log
ERROR: password is easily cracked
DETAIL: cracklib diagnostic: it is based on a dictionary word
STATEMENT: CREATE USER demo PASSWORD 'password123';
3.5.8 Pgstattuple
The pgstattuple_approx function can now be executed on TOAST tables.
Example 97Pgstattuple_approx function
postgres=# SELECT pgstattuple_approx((SELECT reltoastrelid FROM
pg_class WHERE relname='data1')) ;
pgstattuple_approx
-----------------------
(0,0,0,0,0,0,0,0,0,0)
(1 row)
3.5.9 Pg_stat_statements
The following features have been extended to the pg_stat_statements module. When using pg_stat_statements, compute_query_id parameter must be specified as ‘on’ or ‘auto’.
Pg_stat_statements view
The following columns have been added.
Column name
Data type
Description
toplevel
boolean
True if the query was executed as a top level.
Table 29Added columns
PDF page 81
Track utility commands
Tracking is now available for REFRESH MATERIALIZED VIEW statement, CREATE TABLE AS statement, SELECT INTO statement, CREATE MATERIALIZED VIEW statement, etc.
Example 98Tracking REFRESH MATERIALIZED VIEW statement
The pg_stat_statements_info view has been added. This view can be used to check the operational status of the pg_stat_statements module. Currently, the pg_stat_statements view only provides a dealloc column showing the number of SQL statements deleted and a stats_reset column showing the date and time the statistics were reset. The ‘dealloc’ column is used to validate the pg_stat_statements.max parameter.
Example 99Pg_stat_statements_info view
postgres=# \d pg_stat_statements_info
View "public.pg_stat_statements_info"
Column | Type | Collation | Nullable | Default
-------------+--------------------------+-----------+----------+---------
dealloc | bigint | | |
stats_reset | timestamp with time zone | | |
PDF page 82
3.5.10 Pg_trgm
Equality operators are now supported on GiST / GIN indexes.
Example 100Index equation operator
postgres=> CREATE INDEX trgm_idx ON test_trgm
USING gist (t gist_trgm_ops) ;
CREATE INDEX
postgres=> EXPLAIN ANALYZE SELECT * FROM test_trgm
WHERE t='100000' ;
QUERY PLAN
-----------------------------------------------------------------
Index Scan using trgm_idx on test_trgm (cost=0.28..8.30 rows=1
width=5) (actual time=0.424..0.732 rows=1 loops=1)
Index Cond: (t = '100000'::text)
Rows Removed by Index Recheck: 2
Planning Time: 0.038 ms
Execution Time: 0.744 ms
(5 rows)
3.5.11 Pg_surgery
A new Contrib module, pg_surgery, has been added. It provides a function heap_force_freeze to force a tuple to freeze, and a function heap_force_kill to force it to be deleted.
The following enhancements have been implemented for the postgres_fdw module.
Functions
The following functions have been added to control the active session.
PDF page 84
Function name
Description
postgres_fdw_disconnect
Disconnect a specified active session.
postgres_fdw_disconnect_all
Disconnect all active sessions.
postgres_fdw_get_connections
postgres_fdw_get_connections Return all active sessions.
Table 30Added functions
Example 102Execution of postgres_fdw related functions
postgres=> CREATE FOREIGN TABLE remote1(c1 NUMERIC,
c2 VARCHAR(10)) SERVER remsvr1 ;
CREATE FOREIGN TABLE
postgres=> SELECT COUNT(*) FROM remote1 ;
count
---------
1000000
(1 row)
postgres=> SELECT * FROM postgres_fdw_get_connections() ;
server_name | valid
-------------+-------
remsvr1 | t
(1 row)
postgres=> SELECT postgres_fdw_disconnect_all() ;
postgres_fdw_disconnect_all
-----------------------------
t
(1 row)
TRUNCATE statement
The TRUNCATE statement can now be executed on an foreign table.
Supports Bulk Insert
In response to the addition of the Bulk Insert API to the Foreign Data Wrapper, batch_size can now be specified as an option for FOREIGN SERVER and FOREIGN TABLE that use postgres_fdw.
The option keep_connections controls remote connections after a transaction completes. The default value is ‘on’, which keeps the connection after the transaction is completed. Setting this option to ‘off’ closes the connection when the transaction completes.
IMPORT FOREIGN SCHEMA statement
Partitions can now be specified in the LIMIT TO and EXCEPT clauses.
Reconnect
If the session with the remote instance is found to be broken, it will now be reconnected.