本頁面說明如何設定 Cloud SQL 的資料庫旗標,並列出可為執行個體設定的旗標。您可以使用資料庫標記執行許多作業,包括調整 PostgreSQL 參數、調整選項,以及設定及調整執行個體。
在部分情況下,設定某一標記可能會需要您設定另一個標記,才能完整啟用想要的功能。
設定、移除或修改資料庫執行個體的標記時,資料庫可能會重新啟動。移除之前,系統都會保留執行個體的旗標值。如果執行個體是備用資源的來源,且重新啟動執行個體,備用資源也會重新啟動,以便與執行個體的目前設定保持一致。
設定資料庫旗標
設定資料庫旗標
控制台
- 在 Google Cloud 控制台中,選取要設定資料庫旗標的 Cloud SQL 執行個體所在專案。
- 開啟執行個體並按一下 [編輯]。
- 向下捲動至「旗標」區段。
- 如要設定在執行個體中未設定的標記,請按一下「Add item」,從下拉式選單中選擇標記,然後設定其值。
- 按一下 [儲存] 以儲存變更。
- 在「總覽」頁面的「標記」下方,確認您所做的變更。
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
-
如要移除先前透過 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
指令會以要求中指定的值覆寫現有的標記。
將所有標記清除為預設值
控制台
- 在 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
集合。如要進一步瞭解輸出內容中的標記表示法,請參閱「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,400 s
預設值為 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) 陳述式,以及 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
預設為「關閉」。 |
否 | ||||||||||||||||||||
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
您可以使用以半形逗號分隔的清單提供多個類別,並在類別前面加上 |
否 | ||||||||||||||||||||
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 通訊協定版本。目前有效的值為: TLSv1 、TLSv1.1 、TLSv1.2 、TLSv1.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 使用者設定時區,用於顯示和分析時間戳記。 您可以使用名稱指定時區。舉例來說, 您必須在主要執行個體和所有唯讀備用資源上手動更新這個標記,才能對其進行說明。 時區名稱不區分大小寫。您可以以任何大小寫方式提供時區名稱。 我們支援 |
是 | ||||||||||||||||||||
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_delay
和 bgwriter_lru_maxpages
。bgwriter_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 中,您可以指定下列項目。
這些設定會在工作階段關閉後保留,模擬 ALTER DATABASE dbname SET TIMEZONE TO 'timezone'; ALTER USER username SET TIMEZONE TO 'timezone'; 這些設定只會套用至資料庫的新連線。如要查看時區變更,請先中斷與執行個體的連線,然後重新連線。 |
後續步驟
- 進一步瞭解 PostgreSQL 伺服器設定。
- 進一步瞭解操作指南。