設定資料庫旗標

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

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

設定、移除或修改資料庫執行個體的標記時,資料庫可能會重新啟動。移除之前,系統都會保留執行個體的旗標值。如果執行個體是備用資源的來源,且重新啟動執行個體,備用資源也會重新啟動,以便與執行個體的目前設定保持一致。

設定資料庫旗標

設定資料庫旗標

控制台

  1. Google Cloud 控制台中,選取要設定資料庫旗標的 Cloud SQL 執行個體所在專案。
  2. 開啟執行個體並按一下 [編輯]
  3. 向下捲動至「旗標」區段。
  4. 如要設定在執行個體中未設定的標記,請按一下「Add item」,從下拉式選單中選擇標記,然後設定其值。
  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. 如要移除先前透過 Terraform 設定套用的資源,請執行下列指令,並在提示中輸入 yes

    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 集合。如要進一步瞭解輸出內容中的標記表示法,請參閱「Instances Resource Representation」。

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
預設為「關閉」
anon.salt String
沒有預設值。
anon.sourceshema String
預設值為「public」
auto_explain.log_analyze boolean
on | off
預設為「關閉」
auto_explain.log_buffers boolean
on | 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
預設為「關閉」
auto_explain.log_settings boolean
on | off
預設為「關閉」
PostgreSQL 12 以上版本支援此選項。
auto_explain.log_timing boolean
on | off
預設為「開啟」
auto_explain.log_triggers boolean
on | off
預設為「關閉」
auto_explain.log_wal boolean
on | off
預設為「關閉」
PostgreSQL 13 以上版本支援此選項。
auto_explain.log_verbose boolean
on | off
預設為「關閉」
auto_explain.sample_rate Float
0 ... 1
預設值為 1
autovacuum boolean
on | off
預設為「開啟」
如要瞭解可能會影響服務水準協議的用量資訊,請參閱 Cloud SQL 適用的 PostgreSQL 執行個體營運指南
autovacuum_analyze_scale_factor float
0 ... 100
預設值為 0.1
autovacuum_analyze_threshold integer
0 ... 2147483647
預設值為 50
autovacuum_freeze_max_age integer
100000 ... 2000000000
預設值為 200000000
如要瞭解可能會影響服務水準協議的用量資訊,請參閱 Cloud SQL 適用的 PostgreSQL 執行個體營運指南
autovacuum_max_workers integer
1 ... varies (see note)
預設值為 3
autovacuum_multixact_freeze_max_age integer
10000 ... 2000000000
預設值為 400000000
如要瞭解可能會影響服務水準協議的用量資訊,請參閱 Cloud SQL 適用的 PostgreSQL 執行個體營運指南
autovacuum_naptime integer
1 ... 2147483
預設值為 60 秒。
autovacuum_vacuum_cost_delay integer
0 ... 100 ms,或 -1 以使用 vacuum_cost_delay
對於 PostgreSQL 9.6、10 和 11,預設值為 2 ms。
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 秒。
如要瞭解可能會影響服務水準協議的用量資訊,請參閱 Cloud SQL 適用的 PostgreSQL 執行個體營運指南
checkpoint_warning integer
0 ... 2147483647
預設值為 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
預設值為「關閉」
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
預設為「警告」
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
預設為「關閉」
default_transaction_isolation enumeration
serializable | 'repeatable read' | 'read committed' | 'read uncommitted'
預設值為 'read committed'
effective_cache_size integer
大小範圍介於執行個體記憶體的 10% 到 70% 之間。
單位為 8 KB。
預設值為 40% 的 VM 記憶體。舉例來說,如果執行個體記憶體為 45 GB,預設值為 18537160 KB。
effective_io_concurrency integer
0 ... 1000
預設值為 1
enable_async_append boolean
on | off
預設為「開啟」
enable_bitmapscan boolean
on | off
預設為「開啟」
enable_gathermerge boolean
on | off
預設為「開啟」
enable_incremental_sort boolean
on | off
預設為「開啟」
enable_memoize boolean
on | off
預設為「開啟」
enable_parallel_append boolean
on | off
預設為「開啟」
enable_parallel_hash boolean
on | off
預設為「開啟」
enable_partition_pruning boolean
on | off
預設為「開啟」
enable_partitionwise_aggregate boolean
on | off
預設為「關閉」
enable_partitionwise_join boolean
on | off
預設為「關閉」
enable_hashagg boolean
on | off
預設為「開啟」
enable_hashjoin boolean
on | off
預設值為「開啟」
enable_indexonlyscan boolean
on | off
預設值為「開啟」
enable_indexscan boolean
on | off
預設為「開啟」
enable_material boolean
on | off
預設為「開啟」
enable_mergejoin boolean
on | off
預設值為「開啟」
enable_nestloop boolean
on | off
預設為「開啟」
enable_seqscan boolean
on | off
預設值為「開啟」
enable_sort boolean
on | off
預設為「開啟」
enable_tidscan boolean
on | off
預設值為「開啟」
force_parallel_mode enumeration
off | on | regress
預設為「關閉」
from_collapse_limit integer
1 ... 2147483647
預設值為 8
geqo boolean
on | off
預設值為「開啟」
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 ... 2147483647 KB
預設值為 4096 KB。
hash_mem_multiplier float
1 ... 1000
預設值為 2
hot_standby_feedback boolean
on | off
預設為「關閉」
huge_pages enumeration
try | off
預設值為「try」
idle_in_transaction_session_timeout integer
0 ... 2147483647 毫秒
預設值為 0
iffflat.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
預設為「關閉」
log_connections boolean
on | off
預設為「關閉」
log_disconnections boolean
on | off
預設為「關閉」
log_duration boolean
on | off
預設為「關閉」
log_error_verbosity enumeration
terse | default | verbose
預設值為 default
log_executor_stats boolean
on | off
預設為「關閉」
log_hostname boolean
on | off
預設為「關閉」
log_line_prefix String
在記錄檔每行開頭產生的 printf 樣式字串。
預設值為 %m [%p]: [%l-1] db=%d,user=%u,會記錄時間戳記、程序 ID、資料庫和使用者名稱。
log_lock_waits boolean
on | 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
預設為「警告」
log_parser_stats boolean
on | off
預設為「關閉」
log_planner_stats boolean
on | off
預設為「關閉」
log_recovery_conflict_waits boolean
on | off
預設為「關閉」
log_replication_commands boolean
on | 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
small (~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。

如需可能會影響服務水準協議的用量資訊,請參閱 Cloud SQL 適用於 PostgreSQL 執行個體的作業指南
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
預設為「關閉」
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
預設為「開啟」
pg_stat_statements.track enumeration
none | top | all
預設為「top」
pg_stat_statements.track_utility boolean
on | off
預設為「開啟」
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
預設值為「開啟」
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
預設值為「開啟」
synchronize_seqscans boolean
on | off
預設值為「開啟」
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
預設為「關閉」
trace_recovery_messages enumeration
debug5 | debug4 | debug3 | debug2 | debug1 | log | notice | warning | error
預設為「log」
trace_sort boolean
on | off
預設為「關閉」
track_activities boolean
on | off
預設值為「開啟」
track_activity_query_size integer
100 ... 102400
預設值為 1 KB。
track_commit_timestamp boolean
on | off
預設為「關閉」
track_counts boolean
on | off
預設值為「開啟」
track_functions enumeration
none | pl | all
預設值為「none」
track_io_timing boolean
on | 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
預設為「關閉」
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 以毫秒 (ms) 為單位,指定背景寫入器的活動輪次間隔,而 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 其中一個標記時,cloudsqlsuperuser 就能為任何使用者設定 REPLICATION 屬性。

這個標記無法套用至整個例項。

疑難排解

問題 疑難排解
您可以為工作階段設定時區,但在您登出時,時區就會失效。

連結至資料庫,並將資料庫時區設為所需時區 (每位使用者或每個資料庫)。

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

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

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

後續步驟