Skip to content

Commit

Permalink
update postgresql parameters for db investigations
Browse files Browse the repository at this point in the history
  • Loading branch information
alismx committed Jun 9, 2023
1 parent a87238f commit 3e61f02
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 1 deletion.
13 changes: 12 additions & 1 deletion backend/src/main/resources/db/changelog/db.changelog-master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4723,4 +4723,15 @@ databaseChangeLog:
tag: drop-test_order_id-not_null_constraint-from-result
- dropNotNullConstraint:
tableName: result
columnName: test_order_id
columnName: test_order_id
- changeSet:
id: create-pg-stat-statements-extension
author: [email protected]
comment: Install the pg_stat_statements extension.
changes:
- sql:
sql: CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
rollback:
- sql:
sql: -- DROP EXTENSION IF EXISTS pg_stat_statements;
comment: Dropping the extension requires superuser permissions, and we don't want to give that to the migration user, so we have to do nothing here.
46 changes: 46 additions & 0 deletions ops/services/postgres_db/investigation.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# These are disabled by default to avoid performance impact.

# https://www.postgresql.org/docs/current/runtime-config-logging.html
resource "azurerm_postgresql_flexible_server_configuration" "log_min_duration_statement" {
name = "log_min_duration_statement"
server_id = azurerm_postgresql_flexible_server.db.id
# To enable: this is in milliseconds, update this to a positive value in milliseconds to enable this logging
# To disable: update this to -1
value = 30
}

# https://www.postgresql.org/docs/current/runtime-config-statistics.html
resource "azurerm_postgresql_flexible_server_configuration" "track_io_timing" {
name = "track_io_timing"
server_id = azurerm_postgresql_flexible_server.db.id
# To enable: update this to "on" to enable
# To disable: update this to "off"
value = "on"
}

# https://www.postgresql.org/docs/current/pgstatstatements.html
resource "azurerm_postgresql_flexible_server_configuration" "pg_stat_statements_track" {
name = "pg_stat_statements.track"
server_id = azurerm_postgresql_flexible_server.db.id
# To enable: update this to "top" or "all" to enable'
# To disable: update this to "none"
value = "all"
}

# https://www.postgresql.org/docs/current/auto-explain.html
resource "azurerm_postgresql_flexible_server_configuration" "auto_explain_log_analyze" {
name = "auto_explain.log_analyze"
server_id = azurerm_postgresql_flexible_server.db.id
# To enable: update this to "on" to enable
# To disable: update this to "off"
value = "on"
}

# https://www.postgresql.org/docs/current/auto-explain.html
resource "azurerm_postgresql_flexible_server_configuration" "auto_explain_log_min_duration" {
name = "auto_explain.log_min_duration"
server_id = azurerm_postgresql_flexible_server.db.id
# To enable: this is in milliseconds, update this to a positive value in milliseconds to enable this logging
# To disable: update this to -1
value = 30
}
7 changes: 7 additions & 0 deletions ops/services/postgres_db/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,10 @@ resource "azurerm_postgresql_flexible_server_configuration" "pgms_wait_sampling_
server_id = azurerm_postgresql_flexible_server.db.id
value = "ALL"
}

# This allows us to install these extensions on the server
resource "azurerm_postgresql_flexible_server_configuration" "azure_extensions" {
name = "azure.extensions"
server_id = azurerm_postgresql_flexible_server.db.id
value = "PG_STAT_STATEMENTS,PGCRYPTO,PLPGSQL"
}

0 comments on commit 3e61f02

Please sign in to comment.