設定資料庫旗標

本頁說明如何設定 Cloud SQL 的資料庫旗標,並列出可為執行個體設定的旗標。您可以使用資料庫標記執行許多作業,包括調整 PostgreSQL 參數、調整選項,以及設定和調整執行個體。

在部分情況下,設定某一標記可能會需要您設定另一個標記,才能完整啟用想要使用的功能。

設定、移除或修改資料庫執行個體的標記時,資料庫可能會重新啟動。移除之前,系統都會保留執行個體的旗標值。如果執行個體是副本的來源,且執行個體已重新啟動,副本也會重新啟動,以配合執行個體的目前設定。

設定資料庫旗標

下列各節將說明常見的標記管理工作。

設定資料庫旗標

控制台

  1. Google Cloud 控制台中,選取包含要設定資料庫旗標的 Cloud SQL 執行個體的專案。
  2. 開啟執行個體並按一下 [編輯]
  3. 前往「旗標」部分。
  4. 如要設定先前未在執行個體上設定的標記,請按一下「新增項目」,從下拉式選單中選擇標記,然後設定其值。
  5. 按一下 [儲存] 以儲存變更。
  6. 在「總覽」頁面的「標記」下方,確認您所做的變更。

gcloud

編輯執行個體:

gcloud sql instances patch INSTANCE_NAME --database-flags=FLAG1=VALUE1,FLAG2=VALUE2

這項指令會覆寫先前設定的所有資料庫標記。如要保留這些標記並新增標記,請加入要在執行個體上設定的所有標記值;任何未明確加入的標記都會設為預設值。對於未設定值的旗標,請指定旗標名稱,然後加上等號「=」。

舉例來說,如要設定 log_connectionslog_min_error_statement 旗標,可以使用下列指令:

gcloud sql instances patch INSTANCE_NAME \
  --database-flags=log_connections=on,log_min_error_statement=error

Terraform

如要新增資料庫旗標,請使用 Terraform 資源

resource "google_sql_database_instance" "instance" {
  name             = "postgres-instance"
  region           = "us-central1"
  database_version = "POSTGRES_14"
  settings {
    database_flags {
      name  = "log_connections"
      value = "on"
    }
    database_flags {
      name  = "log_min_error_statement"
      value = "error"
    }
    tier = "db-custom-2-7680"
  }
  # set `deletion_protection` to true, will ensure that one cannot accidentally delete this instance by
  # use of Terraform whereas `deletion_protection_enabled` flag protects this instance at the GCP level.
  deletion_protection = false
}

套用變更

如要在 Google Cloud 專案中套用 Terraform 設定,請完成下列各節的步驟。

準備 Cloud Shell

  1. 啟動 Cloud Shell
  2. 設定要套用 Terraform 設定的預設 Google Cloud 專案。

    每項專案只需要執行一次這個指令,且可以在任何目錄中執行。

    export GOOGLE_CLOUD_PROJECT=PROJECT_ID

    如果您在 Terraform 設定檔中設定明確值,環境變數就會遭到覆寫。

準備目錄

每個 Terraform 設定檔都必須有自己的目錄 (也稱為根模組)。

  1. Cloud Shell 中建立目錄,並在該目錄中建立新檔案。檔案名稱的副檔名必須是 .tf,例如 main.tf。在本教學課程中,這個檔案稱為 main.tf
    mkdir DIRECTORY && cd DIRECTORY && touch main.tf
  2. 如果您正在學習教學課程,可以複製每個章節或步驟中的範例程式碼。

    將範例程式碼複製到新建立的 main.tf

    視需要從 GitHub 複製程式碼。如果 Terraform 程式碼片段是端對端解決方案的一部分,建議您使用這個方法。

  3. 查看並修改範例參數,套用至您的環境。
  4. 儲存變更。
  5. 初始化 Terraform。每個目錄只需執行一次這項操作。
    terraform init

    如要使用最新版 Google 供應商,請加入 -upgrade 選項:

    terraform init -upgrade

套用變更

  1. 檢查設定,確認 Terraform 即將建立或更新的資源符合您的預期:
    terraform plan

    視需要修正設定。

  2. 執行下列指令,並在提示中輸入 yes,即可套用 Terraform 設定:
    terraform apply

    等待 Terraform 顯示「Apply complete!」訊息。

  3. 開啟 Google Cloud 專案即可查看結果。在 Google Cloud 控制台中,前往 UI 中的資源,確認 Terraform 已建立或更新這些資源。

刪除變更

如要刪除變更,請按照下列步驟操作:

  1. 如要停用防刪除功能,請在 Terraform 設定檔中將 deletion_protection 引數設為 false
    deletion_protection =  "false"
  2. 執行下列指令,並在提示中輸入 yes,套用更新的 Terraform 設定:
    terraform apply
  1. 執行下列指令,並在提示中輸入 yes,移除先前透過 Terraform 設定套用的資源:

    terraform destroy

REST v1

如要為現有資料庫設定旗標,請按照下列步驟操作:

使用任何要求資料之前,請先替換以下項目:

  • project-id:專案 ID
  • instance-id:執行個體 ID

HTTP 方法和網址:

PATCH https://sqladmin.googleapis.com/v1/projects/project-id/instances/instance-id

JSON 要求主體:

{
  "settings":
  {
    "databaseFlags":
    [
      {
        "name": "flag_name",
        "value": "flag_value"
      }
    ]
  }
}

如要傳送要求,請展開以下其中一個選項:

您應該會收到如下的 JSON 回應:

如果資料庫目前已設有標記,請修改前一指令以併入這些標記。PATCH 指令會以要求中指定的值覆寫現有的標記。

REST v1beta4

如要為現有資料庫設定旗標,請按照下列步驟操作:

使用任何要求資料之前,請先替換以下項目:

  • project-id:專案 ID
  • instance-id:執行個體 ID

HTTP 方法和網址:

PATCH https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/instance-id

JSON 要求主體:

{
  "settings":
  {
    "databaseFlags":
    [
      {
        "name": "flag_name",
        "value": "flag_value"
      }
    ]
  }
}

如要傳送要求,請展開以下其中一個選項:

您應該會收到如下的 JSON 回應:

如果資料庫目前已設有標記,請修改前一指令以併入這些標記。PATCH 指令會以要求中指定的值覆寫現有的標記。

將所有旗標清除為預設值

控制台

  1. Google Cloud 控制台中,選取含有要清除所有標記的 Cloud SQL 執行個體的專案。
  2. 開啟執行個體並按一下 [編輯]
  3. 開啟「資料庫標記」區段。
  4. 按一下畫面上所有顯示標記旁的 [X]
  5. 按一下 [儲存] 以儲存變更。

gcloud

清除執行個體中所有標記並轉為預設值:

gcloud sql instances patch INSTANCE_NAME \
--clear-database-flags

系統會提示您將重新啟動執行個體。

REST v1

清除現有執行個體的所有標記:

使用任何要求資料之前,請先替換以下項目:

  • project-id:專案 ID
  • instance-id:執行個體 ID

HTTP 方法和網址:

PATCH https://sqladmin.googleapis.com/v1/projects/project-id/instances/instance-id

JSON 要求主體:

{
  "settings":
  {
    "databaseFlags": []
  }
}

如要傳送要求,請展開以下其中一個選項:

您應該會收到如下的 JSON 回應:

REST v1beta4

清除現有執行個體的所有標記:

使用任何要求資料之前,請先替換以下項目:

  • project-id:專案 ID
  • instance-id:執行個體 ID

HTTP 方法和網址:

PATCH https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/instance-id

JSON 要求主體:

{
  "settings":
  {
    "databaseFlags": []
  }
}

如要傳送要求,請展開以下其中一個選項:

您應該會收到如下的 JSON 回應:

查看資料庫旗標的現行值

如要檢視 PostgreSQL 設定的所有現行值,請使用 psql 用戶端登入執行個體,然後輸入下列陳述式:

 SELECT name, setting FROM pg_settings;

請注意,您只能變更支援標記的值 (如下所示)。

判斷執行個體已設定哪些資料庫旗標

如要查看 Cloud SQL 執行個體已設定的旗標:

控制台

  1. Google Cloud 控制台中,選取包含 Cloud SQL 執行個體的專案,查看已設定的資料庫標記。
  2. 選取執行個體,開啟「Instance Overview」(執行個體總覽) 頁面。

    在「資料庫標記」區段下方會列出已設定的資料庫標記。

gcloud

取得執行個體狀態:

gcloud sql instances describe INSTANCE_NAME

在輸出中,資料庫標記會列示為 settings 底下的 databaseFlags 集合。如要進一步瞭解輸出內容中的旗標表示法,請參閱執行個體資源表示法

REST v1

列出已針對執行個體設定的標記:

使用任何要求資料之前,請先替換以下項目:

  • project-id:專案 ID
  • instance-id:執行個體 ID

HTTP 方法和網址:

GET https://sqladmin.googleapis.com/v1/projects/project-id/instances/instance-id

如要傳送要求,請展開以下其中一個選項:

您應該會收到如下的 JSON 回應:

在輸出中,找出 databaseFlags 欄位。

REST v1beta4

列出已針對執行個體設定的標記:

使用任何要求資料之前,請先替換以下項目:

  • project-id:專案 ID
  • instance-id:執行個體 ID

HTTP 方法和網址:

GET https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/instance-id

如要傳送要求,請展開以下其中一個選項:

您應該會收到如下的 JSON 回應:

在輸出中,找出 databaseFlags 欄位。

支援的標記

系統不支援下列未提及的旗標。

對於特定標記,Cloud SQL 的支援值或範圍可能會與對應的 PostgreSQL 參數或選項不同。

A | C | D | E | F | G | H | I | J | L | M | O | P | R | S | T | V | W

Cloud SQL 標記 類型
可接受的值與附註
重新啟動
是否需要?
anon.algorithm String
預設值為 sha256
anon.maskschema String
預設值為 mask
anon.restrict_to_trusted_schemas boolean
on | off
預設值為 off
anon.salt String
沒有預設值。
anon.sourceschema String
預設值為「公開」
auto_explain.log_analyze boolean
on | off
預設值為 off
auto_explain.log_buffers boolean
on | off
預設值為 off
auto_explain.log_min_duration Integer
-1 ... 2147483647
預設值為 -1
auto_explain.log_format String
text|xml|json|yaml
預設值為 text
auto_explain.log_level String
debug5|debug4|debug3|debug2|debug1|debug|
info|notice|warning|log
預設值為 log
支援 PostgreSQL 12 以上版本。
auto_explain.log_nested_statements boolean
on | off
預設值為 off
auto_explain.log_settings boolean
on | off
預設為 off
PostgreSQL 12 以上版本支援這項功能。
auto_explain.log_timing boolean
on | off
預設為「開啟」
auto_explain.log_triggers boolean
on | off
預設值為 off
auto_explain.log_wal boolean
on | off
預設為「關閉」
PostgreSQL 13 以上版本支援這項功能。
auto_explain.log_verbose boolean
on | off
預設值為 off
auto_explain.sample_rate Float
0 ... 1
預設值為 1
autovacuum boolean
on | off
預設為「on」
如需可能影響服務等級協議的使用資訊,請參閱 PostgreSQL 適用的 Cloud SQL 執行個體作業指南
autovacuum_analyze_scale_factor float
0 ... 100
預設值為 0.1
autovacuum_analyze_threshold integer
0 ... 2147483647
預設值為 50
autovacuum_freeze_max_age integer
100000 ... 2000000000
預設值為 200000000
如需可能影響服務等級協議的使用資訊,請參閱 PostgreSQL 適用的 Cloud SQL 執行個體作業指南
autovacuum_max_workers integer
1 ... varies (see note)
預設值為 3
autovacuum_multixact_freeze_max_age integer
10000 ... 2000000000
預設值為 400000000
如需可能影響服務等級協議的使用資訊,請參閱 PostgreSQL 適用的 Cloud SQL 執行個體作業指南
autovacuum_naptime integer
1 ... 2147483s
預設值為 60 秒。
autovacuum_vacuum_cost_delay integer
0 ... 100 毫秒,或 -1 使用 vacuum_cost_delay
如果是 PostgreSQL 9.6、10 和 11,預設值為 2 毫秒。
autovacuum_vacuum_cost_limit integer
0 ... 10000,或 -1 以使用 vacuum_cost_limit
預設值為 -1
autovacuum_vacuum_insert_scale_factor float
0 ... 100
預設值為 0.2
autovacuum_vacuum_insert_threshold integer
-1 ... 2147483647
預設值為 1000
autovacuum_vacuum_scale_factor float
0 ... 100
預設值為 0.2
autovacuum_vacuum_threshold integer
0 ... 2147483647
預設值為 50
autovacuum_work_mem integer
0 ... 2147483647 KB,或 -1 以使用 maintenance_work_mem
預設值為 -1
backend_flush_after integer
0 ... 256
單位為 8 KB。
預設值為 0
bgwriter_delay integer
10 ... 10000 毫秒
預設值為 200
bgwriter_flush_after integer
0 ... 256
單位為 8 KB。
預設值為 64
bgwriter_lru_maxpages integer
0 ... 1073741823
預設值為 100
bgwriter_lru_multiplier Float
0 ... 10
預設值為 2
checkpoint_completion_target float
0.0 ... 1.0
預設值為 0.9
checkpoint_flush_after integer
0 ... 256
單位為 8 KB。
預設值為 32
checkpoint_timeout integer
30 ... 86,400s
預設值為 300 秒。
如需可能影響服務等級協議的使用資訊,請參閱 PostgreSQL 適用的 Cloud SQL 執行個體作業指南
checkpoint_warning integer
0 ... 2147483647s
預設值為 30 秒。
client_connection_check_interval integer
0 ... 2147483647
預設值為 0
cloudsql.allow_passwordless_local_connections boolean
on | off
預設值為 off
cloudsql.enable_anon boolean
on | off
預設值為 off
cloudsql.enable_auto_explain boolean
on | off
預設值為 off
cloudsql.enable_index_advisor boolean
on | off
預設值為 off
cloudsql.enable_maintenance_mode boolean
on | off
預設值為 off
cloudsql.enable_pgaudit boolean
on | off
預設為 off
cloudsql.enable_pg_bigm boolean
on | off
預設值:off
cloudsql.enable_pg_cron boolean
on | off
預設值為 off
支援 PostgreSQL 10 以上版本。
cloudsql.enable_pg_hint_plan boolean
on | off
預設值為 off
cloudsql.enable_pglogical boolean
on | off
預設值為 off
cloudsql.enable_pg_squeeze boolean
on | off
預設值為 off
cloudsql.enable_pg_wait_sampling boolean
on | off
cloudsql.iam_authentication boolean
on | off
預設值為 off
cloudsql.logical_decoding boolean
on | off
預設值為 off
cloudsql.max_failed_attempts_user integer
0 ... 10000
預設值為 10
cloudsql.pg_authid_select_role string
commit_delay integer
0 ... 100000
預設值為 0
commit_siblings integer
0 ... 1000
預設值為 5
constraint_exclusion enumeration
partition | on | off
預設值為 partition
cpu_index_tuple_cost float
0.0 ... inf
預設值為 0.005
cpu_operator_cost float
0.0 ... inf
預設值為 0.0025
cpu_tuple_cost float
0.0 ... inf
預設值為 0.01
cron.database_name String
支援 PostgreSQL 10 以上版本。
cron.log_statement boolean
on | off
預設為「開啟」
支援 PostgreSQL 10 以上版本。
cron.log_run boolean
on | off
預設為「開啟」
支援 PostgreSQL 10 以上版本。
cron.max_running_jobs Integer
0 ... varies
預設值為 5
支援 PostgreSQL 10 以上版本。
cron.log_min_messages String
debug5|debug4|debug3|debug2|debug1|debug|
info|notice|warning|error|log|fatal|panic
預設值為 warning
支援 PostgreSQL 10 以上版本。
cursor_tuple_fraction float
0.0 ... 1.0
預設值為 0.1
deadlock_timeout integer
1 ... 2147483647 毫秒
預設值為 1000 毫秒。
default_statistics_target integer
1 ... 10000
預設值為 100
default_tablespace string
default_transaction_deferrable boolean
on | off
預設為 off
default_transaction_isolation enumeration
serializable | 'repeatable read' | 'read committed' | 'read uncommitted'
預設值為 'read committed'
effective_cache_size integer
大小範圍為執行個體記憶體的 10% 至 70%。
單位為 8 KB。
預設值為 VM 記憶體的 40%。舉例來說,如果執行個體記憶體為 45 GB,預設值為 18537160 KB。
effective_io_concurrency integer
0 ... 1000
預設值為 1
enable_async_append boolean
on | off
預設為 on
enable_bitmapscan boolean
on | off
預設為 on
enable_gathermerge boolean
on | off
預設為 on
enable_incremental_sort boolean
on | off
預設為 on
enable_memoize boolean
on | off
預設為 on
enable_parallel_append boolean
on | off
預設為 on
enable_parallel_hash boolean
on | off
預設為 on
enable_partition_pruning boolean
on | off
預設為 on
enable_partitionwise_aggregate boolean
on | off
預設為 off
enable_partitionwise_join boolean
on | off
預設為 off
enable_hashagg boolean
on | off
預設為 on
enable_hashjoin boolean
on | off
預設為 on
enable_indexonlyscan boolean
on | off
預設為 on
enable_indexscan boolean
on | off
預設為 on
enable_material boolean
on | off
預設為「on」
enable_mergejoin boolean
on | off
預設為 on
enable_nestloop boolean
on | off
預設為 on
enable_seqscan boolean
on | off
預設為 on
enable_sort boolean
on | off
預設為 on
enable_tidscan boolean
on | off
預設為 on
force_parallel_mode enumeration
off | on | regress
預設為關閉
from_collapse_limit integer
1 ... 2147483647
預設值為 8
geqo boolean
on | off
預設為 on
geqo_effort integer
1 ... 10
預設值為 5
geqo_generations integer
0 ... 2147483647
預設值為 0
geqo_pool_size integer
0 ... 2147483647
預設值為 0
geqo_seed float
0.0 ... 1.0
預設值為 0
geqo_selection_bias float
1.5 ... 2.0
預設值為 2
geqo_threshold integer
2 ... 2147483647
預設值為 12
gin_fuzzy_search_limit integer
0 ... 2147483647
預設值為 0
gin_pending_list_limit integer
64 ... 2147483647KB
預設值為 4096KB。
hash_mem_multiplier float
1 ... 1000
預設值為 2
hot_standby_feedback boolean
on | off
預設為 off
huge_pages enumeration
try | off
預設值為 try
idle_in_transaction_session_timeout integer
0 ... 2147483647 毫秒
預設值為 0
ivfflat.probes integer
1 ... varies
預設值為 1
PostgreSQL 11 以上版本支援這項功能。
join_collapse_limit integer
1 ... 2147483647
預設值為 8
lock_timeout integer
0 ... 2147483647 毫秒
預設值為 0
log_autovacuum_min_duration integer
0 ... 2147483647 毫秒,或 -1 以停用
預設值為 0
log_checkpoints boolean
on | off
預設為 off
log_connections boolean
on | off
預設為 off
log_disconnections boolean
on | off
預設為 off
log_duration boolean
on | off
預設為 off
log_error_verbosity enumeration
terse | default | verbose
預設值為 default
log_executor_stats boolean
on | off
預設為 off
log_hostname boolean
on | off
預設為 off
log_line_prefix String
在記錄檔每行開頭產生的 printf 樣式字串。
預設值為 %m [%p]: [%l-1] db=%d,user=%u, 會記錄時間戳記、程序 ID、資料庫和使用者名稱。
log_lock_waits boolean
on | off
預設為 off
log_min_duration_statement integer
-1 ... 2147483647 毫秒
預設值為 -1
log_min_error_statement enumeration
debug5 | debug4 | debug3 | debug2 | debug1 | info | notice | warning | error | log | fatal | panic
預設為 error
log_min_messages enumeration
debug5 | debug4 | debug3 | debug2 | debug1 | info | notice | warning | error | log | fatal | panic
預設值為 warning
log_parser_stats boolean
on | off
預設為 off
log_planner_stats boolean
on | off
預設為 off
log_recovery_conflict_waits boolean
on | off
預設為 off
log_replication_commands boolean
on | off
預設為 off
log_statement enumeration
none | ddl | mod | all
設為 mod 可記錄所有資料定義語言 (DDL) 陳述式,以及資料修改陳述式,例如 INSERTUPDATEDELETETRUNCATE
預設值為 none
log_statement_stats boolean
on | off
可能無法與 log_parser_statslog_planner_statslog_executor_stats 一併啟用。
預設為「關閉」
log_temp_files integer
0 ... 2147483647 KB,或 -1 以停用
預設值為 0
log_timezone string
這個旗標可讓 PostgreSQL 適用的 Cloud SQL 使用者設定用於伺服器記錄中時間戳記的時區。

您可以使用名稱指定時區。舉例來說,Europe/London 是倫敦的時區名稱。

您必須在主要執行個體和所有唯讀備用資源上,手動更新這個標記,才能將其納入考量。

時區名稱不區分大小寫。時區名稱不分大小寫。

我們支援 UTC+X 做為這個標記的有效格式,其中 X+/-HH:MM

logical_decoding_work_mem integer
64 ... 2147483647
預設值為 65536
maintenance_io_concurrency integer
0 ... 1000
預設值為 10
maintenance_work_mem integer
1024 ... 2147483647 KB
預設值為 64 MB。
max_connections integer
14 ... varies (see note)
預設值取決於主要執行個體鏈中最大執行個體的記憶體量 (這個執行個體,以及如果是唯讀副本,則包括其主要執行個體、主要執行個體的主要執行個體等,一直到複製樹狀結構的根)。
最大執行個體上的記憶體 (GB)預設值
極小 (~0.5)25
小 (~1.7)50
3.75 至 < 6100
6 至 < 7.5200
7.5 至 < 15400
15 到 < 30500
30 至 < 60600
60 至 < 120800
>=1201,000

備用資源中的值不能小於主要執行個體中的值。主要執行個體的變更會推送到符合下列條件的備用資源:備用資源的值低於主要執行個體的新值,或者備用資源的值仍舊保有預設值。主要執行個體發生這類變更時,備用資源會重新啟動。

max_locks_per_transaction integer
10 ... 2,147,483,647
預設值為 64

備用資源中的值不能小於主要執行個體中的值。主要執行個體的變更會推送到符合下列條件的備用資源:備用資源的值低於主要執行個體的新值,或者備用資源的值仍舊保有預設值。主要執行個體發生這類變更時,備用資源會重新啟動。

max_logical_replication_workers integer
4 ... 8192
預設值為 4
支援 PostgreSQL 10 以上版本。
max_parallel_maintenance_workers integer
0 ... varies
預設值為 2
PostgreSQL 11 以上版本支援這項功能。

備用資源中的值不能小於主要執行個體中的值。主要執行個體的變更會推送到符合下列條件的備用資源:備用資源的值低於主要執行個體的新值,或者備用資源的值仍舊保有預設值。

如果主要執行個體上的值為 default,則無法變更副本的值。如要變更副本的值,請先將主要執行個體的值設為整數。

max_parallel_workers integer
0 ... varies
預設值為 8
PostgreSQL 10 以上版本支援這項功能。

備用資源中的值不能小於主要執行個體中的值。主要執行個體的變更會推送到符合下列條件的備用資源:備用資源的值低於主要執行個體的新值,或者備用資源的值仍舊保有預設值。

如果主要執行個體上的值為 default,則無法變更副本的值。如要變更副本的值,請先將主要執行個體的值設為整數。

max_parallel_workers_per_gather integer
0 ... varies
預設值為 2

備用資源中的值不能小於主要執行個體中的值。主要執行個體的變更會推送到符合下列條件的備用資源:備用資源的值低於主要執行個體的新值,或者備用資源的值仍舊保有預設值。

如果主要執行個體上的值為 default,則無法變更副本的值。如要變更副本的值,請先將主要執行個體的值設為整數。

max_pred_locks_per_page integer
0 ... 2147483647
預設值為 2
支援 PostgreSQL 10 以上版本。
max_pred_locks_per_relation integer
-2147483648 ... 2147483647
預設值為 -2
支援 PostgreSQL 10 以上版本。
max_pred_locks_per_transaction integer
64 ... 1048576
max_prepared_transactions integer
0 ... varies
記憶體大小 (MB)最大值
0 - 3,84030,000
3,840 - 7,68085,000
7,680 - 15,360200,000
15,360 個以上262,000

備用資源中的值不能小於主要執行個體中的值。主要執行個體的變更會推送到符合下列條件的備用資源:備用資源的值低於主要執行個體的新值,或者備用資源的值仍舊保有預設值。主要執行個體發生這類變更時,備用資源會重新啟動。

max_replication_slots integer
10 ... varies
預設值為 10
max_standby_archive_delay integer
0 ... 2147483647 毫秒,或 -1 以永久等候
max_standby_streaming_delay integer
0 ... 2147483647 毫秒,或 -1 以永久等候
max_sync_workers_per_subscription integer
2 ... 64
不得大於 max_logical_replication_workers
max_wal_senders integer
10 ... varies
預設值為 10

備用資源中的值不能小於主要執行個體中的值。主要執行個體的變更會推送到符合下列條件的備用資源:備用資源的值低於主要執行個體的新值,或者備用資源的值仍舊保有預設值。主要執行個體發生這類變更時,備用資源會重新啟動。

max_wal_size integer
2 ... 2147483647

版本 9.6 的單位為 16 MB (WAL 檔案大小),PostgreSQL 10 以上版本的單位為 1 MB。

如果執行個體記憶體大於或等於 3.75 GB,預設值為 1504 MB。如果執行個體記憶體小於 3.75 GB,預設值為 1 GB。

如需可能影響 SLA 的用量資訊,請參閱 PostgreSQL 適用的 Cloud SQL 執行個體作業指南
max_worker_processes integer
8 ... varies

備用資源中的值不能小於主要執行個體中的值。主要執行個體的變更會推送到符合下列條件的備用資源:備用資源的值低於主要執行個體的新值,或者備用資源的值仍舊保有預設值。主要執行個體發生這類變更時,備用資源會重新啟動。

min_parallel_index_scan_size integer
0 ... 715827882
單位為 8 KB
min_parallel_table_scan_size integer
0 ... 715827882
單位為 8 KB
min_parallel_relation_size integer
0 ... 715827882
單位為 8 KB
僅支援 PostgreSQL 9.6。
min_wal_size integer
32 ... 2147483647

版本 9.6 的單位為 16 MB (WAL 檔案大小),PostgreSQL 10 以上版本的單位為 1 MB。

old_snapshot_threshold integer
0 ... 86400 分鐘,或 -1 以停用
預設值為 -1
parallel_setup_cost float
0.0 ... inf
預設值為 1000
parallel_tuple_cost float
0.0 ... inf
預設值為 0.1
password_encryption enumeration
md5 | scram-sha-256

預設值取決於 PostgreSQL 版本。如果是 PostgreSQL 10 至 13 版,預設值為 md5。如果是 PostgreSQL 14 以上版本,預設值為 scram-sha-256

pg_bigm.enable_recheck boolean
on | off
pg_bigm.gin_key_limit integer
0 ... 2147483647
pg_bigm.similarity_limit float
0.0 ... 1.0
pg_hint_plan.enable_hint boolean
on | off
預設為「開啟」
pg_hint_plan.debug_print String
off|on|detailed|verbose|0|1||2|3|no|yes|false|true
預設值為「關閉」
pg_hint_plan.parse_messages String
debug5|debug4|debug3|debug2|debug1|debug|
info|notice|warning|error|log
預設值為 info
pg_hint_plan.message_level String
debug5|debug4|debug3|debug2|debug1|debug|
info|notice|warning|error|log
預設值為 log
pg_hint_plan.enable_hint_table boolean
on | off
預設值為 off
pglogical.batch_inserts boolean
on | off
預設值為 off
pglogical.conflict_log_level String
預設值為 LOG
這個旗標接受的值與 log_min_messages 相同。
pglogical.conflict_resolution String
error|apply_remote|keep_local|last_update_wins|first_update_wins 預設值為 apply_remote
pglogical.extra_connection_options String
接受 PostgreSQL 關鍵字/值連線字串
預設值為空字串。
pglogical.synchronous_commit boolean
on | off
預設值為 on
pglogical.use_spi boolean
on | off
預設值為 off
pg_stat_statements.max integer
100 ... 2147483647
預設值為 5000
pg_stat_statements.save boolean
on | off
預設為 on
pg_stat_statements.track enumeration
none | top | all
預設值為 top
pg_stat_statements.track_utility boolean
on | off
預設為 on
pgaudit.log enumeration
read | write | function | role | ddl | misc | misc_set | all|none

您可以使用以半形逗號分隔的清單提供多個類別,並在類別前加上 - 符號,藉此減去類別。預設值為 none

pgaudit.log_catalog boolean
on | off
預設值為 on
pgaudit.log_client boolean
on | off
預設值為 off
pgaudit.log_level enumeration
debug5 | debug4 | debug3 | debug2 | debug1 | info | notice | warning | error | log
預設值為 log。此外,只有在啟用 pgaudit.log_client 時,pgaudit.log_level 才會啟用。
pgaudit.log_parameter boolean
on | off
預設值為 off
pgaudit.log_relation boolean
on | off
預設值為 off
pgaudit.log_statement_once boolean
on | off
預設值為 off
pgaudit.role string
沒有預設值。
pgtt.enabled boolean
on | off
預設為 on
pg_wait_sampling.history_period integer
1 ... 2147483647
pg_wait_sampling.history_size integer
1 ... 2147483647
pg_wait_sampling.profile_period integer
1 ... 2147483647
pg_wait_sampling.profile_pid boolean
on | off
pg_wait_sampling.profile_queries boolean
on | off
random_page_cost float
0.0 ... inf
預設值為 4
plan_cache_mode

String
auto|force_generic_plan|force_custom_plan
預設值為「auto」
rdkit.agent_FP_bit_ratio float
0 ... 3
rdkit.avalon_fp_size integer
64 ... 9192
rdkit.dice_threshold float
0 ... 1
rdkit.difference_FP_weight_agents integer
-10 ... 10
rdkit.difference_FP_weight_nonagents integer
1 ... 20
rdkit.do_chiral_sss boolean
on | off
rdkit.do_enhanced_stereo_sss boolean
on | off
rdkit.featmorgan_fp_size integer
64 ... 9192
rdkit.hashed_atompair_fp_size integer
64 ... 9192
rdkit.hashed_torsion_fp_size integer
64 ... 9192
rdkit.ignore_reaction_agents boolean
on | off
rdkit.init_reaction boolean
on | off
rdkit.layered_fp_size integer
64 ... 9192
rdkit.morgan_fp_size integer
64 ... 9192
rdkit.move_unmmapped_reactants_to_agents boolean
on | off
rdkit.rdkit_fp_size integer
64 ... 9192
rdkit.reaction_difference_fp_size integer
64 ... 9192
rdkit.reaction_difference_fp_type integer
1 ... 3
rdkit.reaction_sss_fp_size integer
64 ... 9192
rdkit.reaction_sss_fp_type integer
1 ... 5
rdkit.sss_fp_size integer
64 ... 4096
rdkit.tanimoto_threshold float
0 ... 1
rdkit.threshold_unmapped_reactant_atoms float
0 ... 1
replacement_sort_tuples integer
0 ... 2147483647
session_replication_role enumeration
origin | replica | local
只能在目前工作階段中設定
-
seq_page_cost float
0.0 ... inf
預設值為 1.0
shared_buffers integer
大小範圍為執行個體記憶體的 10% 至 60%。
單位為 8 KB。
預設值為執行個體 VM 總記憶體 (以 MB 為單位) 的三分之一。舉例來說,如果執行個體記憶體為 45 GB,預設值為 15085 MB。
squeeze.max_xlock_time integer
1 ... 2147483647
squeeze.worker_autostart string
squeeze.worker_role string
ssl_max_protocol_version enumeration
Postgres 14:設定要使用的 SSL/TLS 通訊協定最高版本。有效值與 ssl_min_protocol_version 相同,但可額外使用空白字串,指定任何通訊協定版本。
支援 PostgreSQL 12 以上版本。
ssl_min_protocol_version enumeration
Postgres 14:設定要使用的最低 SSL/TLS 通訊協定版本。目前有效值為:TLSv1TLSv1.1TLSv1.2TLSv1.3
預設值為 TLSv1
支援 PostgreSQL 12 以上版本。
standard_conforming_strings boolean
on | off
預設為 on
synchronize_seqscans boolean
on | off
預設為 on
tcp_keepalives_count integer
0 ... 2147483647
預設值為 5
tcp_keepalives_idle integer
0 ... 2147483647
預設值為 60
tcp_keepalives_interval integer
0 ... 2147483647
預設值為 60
temp_buffers integer
100 ... 1,073,741,823
單位為 8 KB
temp_file_limit integer
1048576 ... 2147483647 KB
預設值為初始磁碟大小的 10%。 舉例來說,如果是 100 GB 的磁碟,預設值為 10262623 KB。
TimeZone string
這個旗標可讓 PostgreSQL 適用的 Cloud SQL 使用者設定時區,以顯示及分析時間戳記。

您可以使用名稱指定時區。舉例來說,Europe/London 是倫敦的時區名稱。

您必須在主要執行個體和所有唯讀備用資源上,手動更新這個標記,才能將其納入考量。

時區名稱不區分大小寫。時區名稱不分大小寫。

我們支援 UTC+X 做為這個標記的有效格式,其中 X+/-HH

trace_notify boolean
on | off
預設為 off
trace_recovery_messages enumeration
debug5 | debug4 | debug3 | debug2 | debug1 | log | notice | warning | error
預設值為 log
trace_sort boolean
on | off
預設為 off
track_activities boolean
on | off
預設為 on
track_activity_query_size integer
100 ... 102400
預設值為 1 KB。
track_commit_timestamp boolean
on | off
預設為 off
track_counts boolean
on | off
預設為 on
track_functions enumeration
none | pl | all
預設值為 none
track_io_timing boolean
on | off
預設為 off
vacuum_cost_delay integer
0 ... 100 毫秒
預設值為 0
vacuum_cost_limit integer
1 ... 10000
預設值為 200
vacuum_cost_page_dirty integer
0 ... 10000
預設值為 20
vacuum_cost_page_hit integer
0 ... 10000
預設值為 1
vacuum_cost_page_miss integer
0 ... 10000
預設值為 10
vacuum_failsafe_age integer
0 ... 2100000000
預設值為 1600000000
vacuum_freeze_min_age integer
0 ... 1000000000
預設值為 50000000
vacuum_freeze_table_age integer
0 ... 2000000000
預設值為 150000000
vacuum_multixact_failsafe_age integer
0 ... 2100000000
預設值為 1600000000
vacuum_multixact_freeze_min_age integer
0 ... 1000000000
預設值為 5000000
vacuum_multixact_freeze_table_age integer
0 ... 2000000000
預設值為 150000000
wal_buffers integer
大小範圍為執行個體記憶體的 -1% 至 5%。
單位為 8 KB。
預設值為 16 MB。
wal_compression enumeration
off | on | pglz | lz4 | zstd
預設為 off
wal_receiver_timeout integer
0 ... 2147483647
預設值為 60 秒。

這項標記會影響 WAL 傳送者和接收者。 如果未正確設定,這個旗標會影響邏輯和實體複寫。這項標記也會影響複製效能和延遲時間。 如果值為零,系統會停用逾時機制。單位為毫秒。

wal_sender_timeout integer
0 ... 2147483647
預設值為 60 秒。

這項標記會影響 WAL 傳送者和接收者。 如果未正確設定,這個旗標會影響邏輯和實體複寫。這項標記也會影響複製效能和延遲時間。如果值為零,系統會停用逾時機制。 單位為毫秒。

wal_writer_delay integer
1 ... 10000
預設值為 200
wal_writer_flush_after integer
0 ... 2147483647
預設值為 128
work_mem integer
64 ... 2147483647 KB
預設值為 4 MB。

特殊標記

bgwriter

PostgreSQL 具有背景寫入器 (bgwriter) 標記。這個旗標會發出新共用緩衝區或已修改共用緩衝區的寫入作業。這些共用緩衝區稱為「髒緩衝區」。如果乾淨的共用緩衝區數量不足,背景寫入器會將髒緩衝區寫入檔案系統,並標示為乾淨。

bgwriter 旗標相關聯的兩個旗標為 bgwriter_delaybgwriter_lru_maxpagesbgwriter_delay 指定背景寫入器活動回合之間的延遲時間 (以毫秒為單位),bgwriter_lru_maxpages 指定背景寫入器要寫入的緩衝區數量。

bgwriter 旗標的預設值為 200 ms。不過,如果您選取的固態硬碟 (SSD) 大於 500 GB,則 bgwriter_delay 標記的值會設為 50,而 bgwriter_lru_maxpages 標記的值會設為 200

如要進一步瞭解背景寫入器,請參閱 PostgreSQL 說明文件。

session_replication_role

PostgreSQL 具有 session_replication_role 旗標,專為邏輯複製而設計,可讓您在個別工作階段中停用限制觸發程序。

有時,這個旗標也可用於某些維護作業,以規避限制 (最常見的是外鍵) 檢查。

任何具有REPLICATION屬性集的使用者,都可以在工作階段中設定這個旗標。只要為執行個體設定其中一個旗標 ( cloudsql.enable_pglogical cloudsql.logical_decoding),即可為任何使用者設定 REPLICATION 屬性。cloudsqlsuperuser

無法為整個執行個體設定這個標記。

疑難排解

問題 疑難排解
您為工作階段設定的時區會在登出時失效。

連線至資料庫,並將資料庫時區設為所需時區 (可依使用者或資料庫設定)。

在 PostgreSQL 適用的 Cloud SQL 中,您可以指定下列項目。 工作階段關閉後,這些設定仍會保留,模擬 .conf 設定:

ALTER DATABASE dbname SET TIMEZONE TO 'timezone';
ALTER USER username SET TIMEZONE TO 'timezone';

這些設定只會套用至資料庫的新連線。如要查看時區變更,請中斷與執行個體的連線,然後重新連線。

後續步驟