Describes the major enhancements of utility commands.
3.4.1 Configure
The following options have been added to the ‘configure’ command.
Specify SSL library
Added “–with-ssl={library name}” option to specify the SSL library. Also, conventional “–withopenssl” option has been left for compatibility.
Example 76Configure command for SSL
$ ./configure --help | grep ssl
--with-ssl=LIB use LIB for SSL/TLS support (openssl)
--with-openssl obsolete spelling of --with-ssl=openssl
$
Column compression method
The –with-lz4 option has been added to take advantage of the LZ4 column compression feature. The compiler flag LZ4_CFLAGS and the linker flag LZ4_LIBS have been added as environment variables.
Example 77Configure command for LZ4
$ ./configure --help | grep -i lz4
--with-lz4 build with LZ4 support
LZ4_CFLAGS C compiler flags for LZ4, overriding pkg-config
LZ4_LIBS linker flags for LZ4, overriding pkg-config
$
3.4.2 Initdb
The following options have been added to the initdb command.
–no-instructions option
When this option is specified, a message indicating the instance start-up method will not be output.
PDF page 67
Example 78--no-instructions option
$ initdb -D data --no-instructions
The files belonging to this database system will be owned by user
"postgres".
This user must also own the server process.
…
initdb: warning: enabling "trust" authentication forlocalconnections
You can change this by editing pg_hba.conf or using the option -
A, or
--auth-local and --auth-host, the next time you run initdb.
–data-checksums option
In the message output when the –help option is specified, the –data-checksums option that specifies the checksum has been promoted from “Less commonly used options:” to the commonly used option “Options:”.
Example 79Checksum specification option
$ initdb --help
initdb initializes a PostgreSQL database cluster.
Usage:
initdb [OPTION]... [DATADIR]Options:
-A, --auth=METHOD default authentication method forlocal connections
--auth-host=METHOD default authentication method forlocal TCP/IP
connections
--auth-local=METHOD default authentication method for local-socket
connections
[-D, --pgdata=]DATADIR location for this database cluster
-E, --encoding=ENCODING set default encoding for new databases
-g, --allow-group-access allow group read/execute on data directory
-k, --data-checksums use data page checksums
--locale=LOCALE set default locale for new databases
–clobber-cache option
…
PDF page 68
–discard-cache option
Run the bootstrap backend with the debug_discard_caches=1 option. This takes a very long time and is only of use for debugging.
3.4.3 Pg_amcheck
The pg_amcheck command has been added. This command makes it easy to check the structure of tables and indexes against a database with the Contrib module amcheck installed. In the following example, it can be seen that the damaged part of data2 table.
Example 80Pg_amcheck command
$ pg_amcheck --database=postgres --table=data2 --verbose
pg_amcheck: including database: "postgres"pg_amcheck: in database "postgres": using amcheck version "1.3" in
schema "public"pg_amcheck: checking heap table "postgres"."public"."data2"heap table "postgres"."public"."data2", block 0, offset 17:
xmin 3236212 equals or exceeds next valid transaction ID 0:546
heap table "postgres"."public"."data2", block 0, offset 48:
line pointer to page offset 6282 is not maximally aligned
pg_amcheck:
checking
btree
index
"postgres"."pg_toast"."pg_toast_16399_index"pg_amcheck:
checking
heap
table
"postgres"."pg_toast"."pg_toast_16399"
Many options can be specified for the pg_amcheck command other than the above example.
PDF page 69
Option name
Description
–all
Check all databases.
–index=PATTERN
Check matching index(es).
–schema=PATTERN
Check matching schema(s).
–on-error-stop
Stop checking at end of first corrupt page.
–parent-check
Check index parent/child relationships.
–startblock=BLOCK
Begin checking table(s) at the given block number.
–endblock=BLOCK
Check table(s) only up to the given block number.
–jobs=NUM
Use this many concurrent connections to the server.
–progress
Show progress information.
Table 27Major options
3.4.4 Pg_dump
The pg_dump command has been following enhancements are implemented.
Restore partitions
It is now possible to restore a single partition from the partitioned table as a table.
Dumping Extension settings
The –extension option has been added to limit the extension definitions to be dumped. Specify the pattern for the extension name.
In the pg_dump command, pg_dumpall command, pg_restore command, and pg_rewind command, specifying the -v option multiple times will now increase the output level of the log.
3.4.5 Pg_dumpall
The pg_dumpall command now has an option –no-toast-compression that does not dump the compression settings for TOAST data.
3.4.6 Pg_rewind
It is now possible to specify a standby instance of streaming replication as the connection destination.
3.4.7 Psql
The following features have been added to the psql command.
Displaying access methods
The Access Method is now output to the output of the \di+, \dm+, \dt+, and \dtS+ commands.
Example 82Display access method
postgres=> \di+
List of relations
Schema | Name | Type | Owner | Table | Persistence | Access Method | …
--------+------------+-------+-------+-------+-------------+-------------+ …
public | idx1_data1 | index | demo | data1 | permanent | btree | …
public | idx1_data2 | index | demo | data2 | permanent | btree | …
(2 rows)
postgres=> \dt+
List of relations
Schema | Name | Type | Owner | Persistence | Access Method | …
--------+---------+-------------------+-------+-------------+-----------+ …-
public | data1 | table | demo | permanent | heap | …
public | data2 | table | demo | permanent | heap | …
(2 rows)
PDF page 71
\dt, \di command
It is now possible to specify for TOAST table and TOAST index.
Example 83Specifying the TOAST table
postgres=> \dt pg_toast.pg_toast_16384
List of relations
Schema | Name | Type | Owner
----------+----------------+-------------+----------
pg_toast | pg_toast_16384 | TOAST table | postgres
(1 row)
postgres=> \di pg_toast.pg_toast_1213_index
List of relations
Schema | Name | Type | Owner | Table
----------+---------------------+-------+----------+-------------
pg_toast | pg_toast_1213_index | index | postgres | pg_toast_1213
(1 row)
\dX command
Outputs a list of extended statistics.
Example 84List of extended statistics
postgres=> CREATE STATISTICS stat1_data1 ON c1, c2 FROM data1 ;
CREATE STATISTICS
postgres=> ANALYZE data1 ;
ANALYZE
postgres=> \dX
List of extended statistics
Schema | Name | Definition | Ndistinct | Dependencies | MCV
--------+-------------+-------------------+-----------+--------------+------
public | stat1_data1 | c1, c2 FROM data1 | defined | defined | defined
(1 row)
PDF page 72
\d+ command
When the table name is specified in the \d+ command, a compression setting column (Compression) is output between the Storage and Stats target columns. This column can be suppressed by setting the HIDE_TOAST_COMPRESSION variable to ‘on’.
postgres=> \do - pg_catalog.int4
List of operators
Schema | Name | Left arg type | Right arg type | Result type | Description
------------+------+---------------+----------------+-------------+-----------
pg_catalog | - | | integer | integer | negate
(1 row)
postgres=> \df sum (numeric)
List of functions
Schema | Name | Result data type | Argument data types | Type
------------+------+------------------+---------------------+------
pg_catalog | sum | numeric | numeric | agg
(1 row)
\dT command
The \dT command now accepts alias names for data types.
Example 87\dT command with alias
postgres=> \dT int
List of data types
Schema | Name | Description
------------+---------+-------------------------------------------------
pg_catalog | integer | -2 billion to 2 billion integer, 4-byte storage
(1 row)
Behavior when the editor is closed
The \e command (also \ef and \ev commands) launches the editor and no longer re-executes SQL statements in the file if the file is not modified.
3.4.8 Reindexdb
The –tablespace option has been added to the reindexdb command. It is now possible to specify the tablespace in which to store the indexes to be recreated.
PDF page 74
Example 88REINDEXDB --tablespace option
$ reindexdb --table=data1 --tablespace=ts1 --verbose postgres
INFO: index "idx1_data1" was reindexed
DETAIL: CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.00 s
INFO: index "pg_toast_16385_index" was reindexed
DETAIL: CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.00 s
3.4.9 Vacuumdb
The following options have been added to the vacuumdb command.
–force-index-cleanup option
Always remove index entries pointing to dead tuples.
–no-index-cleanup option
Do not delete unnecessary tuples in the index.
–no-truncate option
Do not truncate the free pages at the end of the table.
–no-process-toast option
Do not perform VACUUM processing on the TOAST table.
PDF page 75
Example 89Vacuumdb command options
$vacuumdb--help
vacuumdbcleansandanalyzesaPostgreSQLdatabase.Usage:vacuumdb[OPTION]...[DBNAME]Options:-a,--all vacuum all databases
-d,--dbname=DBNAME database to vacuum
--disable-page-skipping disable all page-skipping behavior
-e,--echo show the commands being sent to the server
-f,--full do full vacuuming
-F,--freeze freeze row transaction information
--force-index-cleanup always remove index entries that point to
deadtuples-j,--jobs=NUM use this many concurrent connections to vacuum
--min-mxid-age=MXID_AGE minimum multixact ID age of tables to vacuum
--min-xid-age=XID_AGE minimum transaction ID age of tables to
vacuum--no-index-cleanup don't remove index entries that point to dead
tuples--no-process-toast skip the TOAST table associated with the
tabletovacuum--no-truncate don't truncate empty pages at the end of the
table-P,--parallel=PARALLEL_WORKERS use this many background workers for vacuum,
ifavailable…