Skip to main content

Azure Database for PostgreSQL flexible server

Azure Database for PostgreSQL flexible server agent setup

For an overview of how the DBtune agent works, see agent overview.

Prerequisites

Before starting the DBtune agent, there is some setup you are required to complete on your database.

Azure Database for PostgreSQL flexible server requires you to allow specific extensions explicitly before they can be used, pg_stat_statements (which the DBtune agent requires) is one of these. First, allowlist the extension by adding it to the azure.extensions server parameter.

After pg_stat_statements is enabled, you will also need to update the pg_stat_statements.track server parameter. By default this will be set to off, it needs to be set to either top or all for the extension to collect the information DBtune requires.

Once you have setup pg_stat_statements, ensure you have completed the remaining database setup steps.

Azure managed identity IAM permissions

The agent is setup to utilize the managed identity attached to an Azure Virtual Machine. The IAM role associated with those credentials is required to be able to perform the following actions:

"actions": [
"Microsoft.DBforPostgreSQL/flexibleServers/restart/action",
"Microsoft.DBforPostgreSQL/flexibleServers/read",
"Microsoft.DBforPostgreSQL/flexibleServers/providers/Microsoft.Insights/metricDefinitions/read",
"Microsoft.DBforPostgreSQL/flexibleServers/configurations/read",
"Microsoft.DBforPostgreSQL/flexibleServers/configurations/write",
"Microsoft.Insights/metrics/read",
"Microsoft.Insights/metricDefinitions/read"
]

Setting up the agent

Run the DBtune agent using Docker with PostgreSQL flexible server-specific configuration:

docker run --restart always \
-e DBT_POSTGRESQL_CONNECTION_URL="postgresql://..." \
-e DBT_AZURE_FLEX_SUBSCRIPTION_ID=your-subscription-id \
-e DBT_AZURE_FLEX_RESOURCE_GROUP_NAME=your-resource-group-name \
-e DBT_AZURE_FLEX_SERVER_NAME=your-flexible-server-name
-e DBT_DBTUNE_SERVER_URL=https://app.dbtune.com \
-e DBT_DBTUNE_API_KEY=your-dbtune-api-key \
-e DBT_DBTUNE_DATABASE_ID=your-dbtune-database-id \
public.ecr.aws/dbtune/dbtune/agent:latest

For information about common environment variables (DBT_DBTUNE_* and DBT_POSTGRESQL_*), see agent overview - common environment variables.

Azure Database for PostgreSQL flexible server-specific environment variables

VariableDescription
DBT_AZURE_FLEX_SUBSCRIPTION_IDThe ID of the Azure subscription that your PostgreSQL Felible Server instance is in.
DBT_AZURE_FLEX_RESOURCE_GROUP_NAMEThe name of the Resource Group that your PostgreSQL Flexible Server instance is in.
DBT_AZURE_FLEX_SERVER_NAMEThe name of your PostgreSQL flexible server instance.

Parameters tuned

DBtune supports multiple tuning modes that determine which parameters can be optimized. For a detailed explanation of tuning modes, see tuning modes.

Reload-only tuning mode

The following parameters are tuned in reload-only mode:

The following parameters are tuned in reload-only mode:

  1. work_mem
  2. random_page_cost
  3. seq_page_cost
  4. checkpoint_completion_target
  5. effective_io_concurrency
  6. max_parallel_workers_per_gather
  7. max_parallel_workers
  8. max_wal_size
  9. min_wal_size
  10. bgwriter_lru_maxpages
  11. bgwriter_delay
  12. default_statistics_target
  13. max_parallel_maintenance_workers

Restart tuning mode

Currently, restart tuning mode is not supported for Azure Database for PostrgeSQL flexible server.