本頁說明如何設定 Cloud SQL 的資料庫旗標,並列出可為執行個體設定的旗標。您可以使用資料庫標記執行許多作業,包括調整 PostgreSQL 參數、調整選項,以及設定和調整執行個體。
在部分情況下,設定某一標記可能會需要您設定另一個標記,才能完整啟用想要使用的功能。
設定、移除或修改資料庫執行個體的標記時,資料庫可能會重新啟動。移除之前,系統都會保留執行個體的旗標值。如果執行個體是副本的來源,且執行個體已重新啟動,副本也會重新啟動,以配合執行個體的目前設定。
設定資料庫旗標
下列各節將說明常見的標記管理工作。
設定資料庫旗標
控制台
- 在 Google Cloud 控制台中,選取包含要設定資料庫旗標的 Cloud SQL 執行個體的專案。
- 開啟執行個體並按一下 [編輯]。
- 前往「旗標」部分。
- 如要設定先前未在執行個體上設定的標記,請按一下「新增項目」,從下拉式選單中選擇標記,然後設定其值。
- 按一下 [儲存] 以儲存變更。
- 在「總覽」頁面的「標記」下方,確認您所做的變更。
gcloud
編輯執行個體:
gcloud sql instances patch INSTANCE_NAME --database-flags=FLAG1=VALUE1,FLAG2=VALUE2
這項指令會覆寫先前設定的所有資料庫標記。如要保留這些標記並新增標記,請加入要在執行個體上設定的所有標記值;任何未明確加入的標記都會設為預設值。對於未設定值的旗標,請指定旗標名稱,然後加上等號「=」。
舉例來說,如要設定 log_connections
和 log_min_error_statement
旗標,可以使用下列指令:
gcloud sql instances patch INSTANCE_NAME \ --database-flags=log_connections=on,log_min_error_statement=error
Terraform
如要新增資料庫旗標,請使用 Terraform 資源。
套用變更
如要在 Google Cloud 專案中套用 Terraform 設定,請完成下列各節的步驟。
準備 Cloud Shell
- 啟動 Cloud Shell。
-
設定要套用 Terraform 設定的預設 Google Cloud 專案。
每項專案只需要執行一次這個指令,且可以在任何目錄中執行。
export GOOGLE_CLOUD_PROJECT=PROJECT_ID
如果您在 Terraform 設定檔中設定明確值,環境變數就會遭到覆寫。
準備目錄
每個 Terraform 設定檔都必須有自己的目錄 (也稱為根模組)。
-
在 Cloud Shell 中建立目錄,並在該目錄中建立新檔案。檔案名稱的副檔名必須是
.tf
,例如main.tf
。在本教學課程中,這個檔案稱為main.tf
。mkdir DIRECTORY && cd DIRECTORY && touch main.tf
-
如果您正在學習教學課程,可以複製每個章節或步驟中的範例程式碼。
將範例程式碼複製到新建立的
main.tf
。視需要從 GitHub 複製程式碼。如果 Terraform 程式碼片段是端對端解決方案的一部分,建議您使用這個方法。
- 查看並修改範例參數,套用至您的環境。
- 儲存變更。
-
初始化 Terraform。每個目錄只需執行一次這項操作。
terraform init
如要使用最新版 Google 供應商,請加入
-upgrade
選項:terraform init -upgrade
套用變更
-
檢查設定,確認 Terraform 即將建立或更新的資源符合您的預期:
terraform plan
視需要修正設定。
-
執行下列指令,並在提示中輸入
yes
,即可套用 Terraform 設定:terraform apply
等待 Terraform 顯示「Apply complete!」訊息。
- 開啟 Google Cloud 專案即可查看結果。在 Google Cloud 控制台中,前往 UI 中的資源,確認 Terraform 已建立或更新這些資源。
刪除變更
如要刪除變更,請按照下列步驟操作:
- 如要停用防刪除功能,請在 Terraform 設定檔中將
deletion_protection
引數設為false
。deletion_protection = "false"
- 執行下列指令,並在提示中輸入
yes
,套用更新的 Terraform 設定:terraform apply
-
執行下列指令,並在提示中輸入
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
指令會以要求中指定的值覆寫現有的標記。
將所有旗標清除為預設值
控制台
- 在 Google Cloud 控制台中,選取含有要清除所有標記的 Cloud SQL 執行個體的專案。
- 開啟執行個體並按一下 [編輯]。
- 開啟「資料庫標記」區段。
- 按一下畫面上所有顯示標記旁的 [X]。
- 按一下 [儲存] 以儲存變更。
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 執行個體已設定的旗標:
控制台
- 在 Google Cloud 控制台中,選取包含 Cloud SQL 執行個體的專案,查看已設定的資料庫標記。
- 選取執行個體,開啟「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 ... 2147483 s
預設值為 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,400 s
預設值為 300 秒。 如需可能影響服務等級協議的使用資訊,請參閱 PostgreSQL 適用的 Cloud SQL 執行個體作業指南。 |
否 | ||||||||||||||||||||
checkpoint_warning | integer 0 ... 2147483647 s
預設值為 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 ... 2147483647 KB
預設值為 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) 陳述式,以及資料修改陳述式,例如 INSERT 、UPDATE 、DELETE 、TRUNCATE
預設值為 none。 |
否 | ||||||||||||||||||||
log_statement_stats | boolean on | off
可能無法與 log_parser_stats 、log_planner_stats 或 log_executor_stats 一併啟用。
預設為「關閉」。 |
否 | ||||||||||||||||||||
log_temp_files | integer 0 ... 2147483647 KB,或 -1 以停用
預設值為 0。 |
否 | ||||||||||||||||||||
log_timezone | string 這個旗標可讓 PostgreSQL 適用的 Cloud SQL 使用者設定用於伺服器記錄中時間戳記的時區。 您可以使用名稱指定時區。舉例來說, 您必須在主要執行個體和所有唯讀備用資源上,手動更新這個標記,才能將其納入考量。 時區名稱不區分大小寫。時區名稱不分大小寫。 我們支援 |
是 | ||||||||||||||||||||
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)
預設值取決於主要執行個體鏈中最大執行個體的記憶體量 (這個執行個體,以及如果是唯讀副本,則包括其主要執行個體、主要執行個體的主要執行個體等,一直到複製樹狀結構的根)。
備用資源中的值不能小於主要執行個體中的值。主要執行個體的變更會推送到符合下列條件的備用資源:備用資源的值低於主要執行個體的新值,或者備用資源的值仍舊保有預設值。主要執行個體發生這類變更時,備用資源會重新啟動。 |
是 | ||||||||||||||||||||
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 以上版本支援這項功能。 備用資源中的值不能小於主要執行個體中的值。主要執行個體的變更會推送到符合下列條件的備用資源:備用資源的值低於主要執行個體的新值,或者備用資源的值仍舊保有預設值。 如果主要執行個體上的值為 |
否 | ||||||||||||||||||||
max_parallel_workers | integer 0 ... varies
預設值為 8。 PostgreSQL 10 以上版本支援這項功能。 備用資源中的值不能小於主要執行個體中的值。主要執行個體的變更會推送到符合下列條件的備用資源:備用資源的值低於主要執行個體的新值,或者備用資源的值仍舊保有預設值。 如果主要執行個體上的值為 |
否 | ||||||||||||||||||||
max_parallel_workers_per_gather | integer 0 ... varies
預設值為 2。 備用資源中的值不能小於主要執行個體中的值。主要執行個體的變更會推送到符合下列條件的備用資源:備用資源的值低於主要執行個體的新值,或者備用資源的值仍舊保有預設值。 如果主要執行個體上的值為 |
否 | ||||||||||||||||||||
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
備用資源中的值不能小於主要執行個體中的值。主要執行個體的變更會推送到符合下列條件的備用資源:備用資源的值低於主要執行個體的新值,或者備用資源的值仍舊保有預設值。主要執行個體發生這類變更時,備用資源會重新啟動。 |
是 | ||||||||||||||||||||
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。 如果執行個體記憶體大於或等於 |
否 | ||||||||||||||||||||
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 版,預設值為 |
否 | ||||||||||||||||||||
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
您可以使用以半形逗號分隔的清單提供多個類別,並在類別前加上 |
否 | ||||||||||||||||||||
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 通訊協定版本。目前有效值為: TLSv1 、TLSv1.1 、TLSv1.2 、TLSv1.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 使用者設定時區,以顯示及分析時間戳記。 您可以使用名稱指定時區。舉例來說, 您必須在主要執行個體和所有唯讀備用資源上,手動更新這個標記,才能將其納入考量。 時區名稱不區分大小寫。時區名稱不分大小寫。 我們支援 |
是 | ||||||||||||||||||||
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_delay
和 bgwriter_lru_maxpages
。bgwriter_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 中,您可以指定下列項目。
工作階段關閉後,這些設定仍會保留,模擬 ALTER DATABASE dbname SET TIMEZONE TO 'timezone'; ALTER USER username SET TIMEZONE TO 'timezone'; 這些設定只會套用至資料庫的新連線。如要查看時區變更,請中斷與執行個體的連線,然後重新連線。 |
後續步驟
- 進一步瞭解 PostgreSQL 伺服器設定。
- 進一步瞭解操作指南。