5.9. Databases #
This section explains how to manage databases. It contains the following instructions:
Creating a Database
In the navigation panel, go to Databases.
In the top-right corner of the page, click Create database.
Enter parameters of the new database (parameters marked with an asterisk are required):
Instance: The instance where the database will be created.
Database name.
Database owner.
Encoding (ENCODING): The character encoding in the database.
Sorting category (LC_COLLATE): Specifies the
LC_COLLATEvalue in the operating system environment of the database server.Category of symbol types (LC_CTYPE): Specifies the
LC_CTYPEvalue in the operating system environment of the database server.Tablespace: The tablespace where the database will be created.
Allow connections: Specifies whether the database will be available for connections.
Limiting the number of connections: The maximum number of simultaneous database sessions.
Is template: Specifies whether the created database will be a template.
Template: The template of the database.
Click Save.
Viewing Databases
In the navigation panel, go to Databases.
(Optional) To display system databases, turn on Show system databases.
The table of databases includes the following columns:
DB name.
Total size.
The horizontal indicator displays the size of tables, bloat, and indexes.
Wraparound: The percentage of released transaction IDs in the database.
Instance: The instance where the database is created.
Data collecting: The amount of the instance service information collected by agents.
Tables:
the number of tables
the size of tables
the table bloat percentage
Indexes:
the number of indexes
the size of indexes
the index bloat percentage
Actions.
For more information about available actions, refer to other instructions in this section.
The database size is calculated as the total sum of all its relational objects. This allows avoiding redundant calls of the pg_database_size function that uses the recursive traversal of directories and files and can negatively impact the performance of the main instance workload.
Important
If a database is created outside PPEM, the information about it can be displayed in the web application with a delay. The delay duration depends on the agent configuration. By default, it is one minute.
Starting the psql Terminal
The psql terminal provides low-level access to the DBMS instance and can be used when PPEM features are not sufficient. Although providing most of the standard psql functionality, it has certain limitations. For example, you cannot use the \! meta-command to run shell commands.
The DBMS instance connection parameters are used when the terminal is started.
To start the psql terminal:
In the navigation panel, go to Databases.
(Optional) To display system databases, turn on Show system databases.
Click PSQL next to the database.
Collecting the Planner Statistics for a Database
The ANALYZE SQL command is executed when collecting the planner statistics.
To collect the planner statistics for a database:
In the navigation panel, go to Databases.
(Optional) To display system databases, turn on Show system databases.
Click
→ Analyze next to the database.
Specify the statistics collection parameters (parameters marked with an asterisk are required):
Set cron-string execution: Allows specifying the time interval for collecting statistics in the crontab format.
If you turn on this toggle, in Execution, enter the string.
Task planning: The type of the statistics collection task.
Possible values:
Execute now: The statistics will be collected immediately after you perform this instruction.
Time-delayed: The statistics will be collected at the specified date and time.
On schedule: The statistics will be collected at the specified time interval.
For this value, specify the following parameters:
Interval: The unit of measurement of the time interval.
Possible values:
Minutes
Hours
Days
Repeat every: The time interval for collecting statistics by minutes or hours.
This parameter is available only if you select Minutes or Hours from Interval.
Execution days: The days when statistics will be collected.
Cron total line: The string in the crontab format that specifies the time interval for collecting statistics.
The value is entered automatically.
This parameter is available only if you turn off Set cron-string execution.
Name: The unique name of the statistics collection task.
This parameter is available only if you turn on Set cron-string execution or select Time-delayed / On schedule from Task planning.
Time: The date and/or time when statistics will be collected.
This parameter is available only if you select Time-delayed from Task planning or Days from Interval.
Start and Repeat untill: The start and end date and time for the statistics collection.
These parameters are available only if you turn on Set cron-string execution or select On schedule from Task planning.
Click Apply.
Confirm the operation.
The statistics collection will start in the asynchronous mode.
Note
Depending on the number of tables and columns, this operation may require significant resources so it is recommended to track it.
Reindexing a Database
The REINDEX SQL command is executed when reindexing.
To reindex a database:
In the navigation panel, go to Databases.
(Optional) To display system databases, turn on Show system databases.
Click
→ Reindex next to the database.
Specify the reindexing parameters (parameters marked with an asterisk are required):
Set cron-string execution: Allows specifying the time interval for reindexing in the crontab format.
If you turn on this toggle, in Execution, enter the string.
Task planning: The type of the reindexing task.
Possible values:
Execute now: Reindexing will be performed immediately after you perform this instruction.
Time-delayed: Reinxdexing will be performed at the specified date and time.
On schedule: Reindexing will be performed at the specified time interval.
For this value, specify the following parameters:
Interval: The unit of measurement of the time interval.
Possible values:
Minutes
Hours
Days
Repeat every: The time interval for reindexing by minutes or hours.
This parameter is available only if you select Minutes or Hours from Interval.
Execution days: The days when reindexing will be performed.
Cron total line: The string in the crontab format that specifies the time interval for reindexing.
The value is entered automatically.
This parameter is available only if you turn off Set cron-string execution.
Name: The unique name of the reindexing task.
This parameter is available only if you turn on Set cron-string execution or select Time-delayed / On schedule from Task planning.
Time: The date and/or time when reindexing will be performed.
This parameter is available only if you select Time-delayed from Task planning or Days from Interval.
Start and Repeat untill: The start and end date and time for reindexing.
These parameters are available only if you turn on Set cron-string execution or select On schedule from Task planning.
Confirm the operation.
Note
Depending on the number and size of indexes, this operation may require significant resources so it is recommended to track it.
Vacuuming a Database
The VACUUM SQL command is executed when vacuuming.
To vacuum a database:
In the navigation panel, go to Databases.
(Optional) To display system databases, turn on Show system databases.
Click
→ Vacuum next to the database.
Specify the vacuum parameters (parameters marked with an asterisk are required):
Modes: The vacuum modes.
Possible values:
Analyze: Updates the statistics that the planner uses for selecting the most efficient way of query execution.
Full: Performs a full vacuum via reindexing all table files.
Note
While the vacuum is being performed in this mode, all sessions working with tables that are being reindexed will be blocked.
Freeze: Performs an aggressive tuple freeze to expand freezing and release transaction IDs for further reuse.
The aggressive freeze is always performed when overwriting the table, so do not select Freeze if Full is already selected.
Set cron-string execution: Allows specifying the time interval for vacuuming in the crontab format.
If you turn on this toggle, in Execution, enter the string.
Task planning: The type of the vacuuming task.
Possible values:
Execute now: Vacuuming will be performed immediately after you perform this instruction.
Time-delayed: Vacuuming will be performed at the specified date and time.
On schedule: Vacuuming will be performed at the specified time interval.
For this value, specify the following parameters:
Interval: The unit of measurement of the time interval.
Possible values:
Minutes
Hours
Days
Repeat every: The time interval for vacuuming by minutes or hours.
This parameter is available only if you select Minutes or Hours from Interval.
Execution days: The days when vacuuming will be performed.
Cron total line: The string in the crontab format that specifies the time interval for vacuuming.
The value is entered automatically.
This parameter is available only if you turn off Set cron-string execution.
Name: The unique name of the vacuuming task.
This parameter is available only if you turn on Set cron-string execution or select Time-delayed / On schedule from Task planning.
Time: The date and/or time when vacuuming will be performed.
This parameter is available only if you select Time-delayed from Task planning or Days from Interval.
Start and Repeat untill: The start and end date and time for vacuuming.
These parameters are available only if you turn on Set cron-string execution or select On schedule from Task planning.
Click Apply.
Confirm the operation.
Note
Depending on the number and size of tables, this operation may require significant resources so it is recommended to track it.
Renaming a Database
The ALTER DATABASE SQL command is executed with the RENAME TO clause when renaming a database.
To rename a database:
In the navigation panel, go to Databases.
(Optional) To display system databases, turn on Show system databases.
Click
→ Rename next to the database.
Specify the new database name.
Click Save.
Deleting a Database
The DROP DATABASE SQL command is executed when deleting a database.
Important
Deleted databases cannot be restored.
To delete a database:
In the navigation panel, go to Databases.
(Optional) To display system databases, turn on Show system databases.
Click
→ Drop next to the database.
(Optional) To force delete the database, enable Forced deletion.
If you enable this checkbox, all database connections will be terminated before deleting the database.
The database will not be deleted if there are prepared transactions, logical replication slots, or subscriptions.
Click Delete.
Confirm the operation.