Description
log_temp_files records a temporary file’s name and size when PostgreSQL deletes it. A positive value sets the minimum size in KB, 0 records every file and -1 disables this logging.
Potential impact
A high threshold can hide part of a query’s disk usage. Logging every file can increase log volume and cost.
Remediation
Choose the smallest file size you need to investigate and set log_temp_files in settings.database_flags. On an existing instance, update the flags in Cloud SQL and retain the other flags you need. Check log volume, performance, access and retention.
Examples
The google.cloud 1.14.0 example configures a new instance. Supply a supported PostgreSQL version and tier, your project and instance names, and a service account JSON file.
Before
- name: Cloud SQL 인스턴스 생성
google.cloud.gcp_sql_instance:
auth_kind: serviceaccount
database_version: POSTGRES_13
name: "{{ resource_name }}-2"
project: test_project
region: us-central1
service_account_file: /tmp/auth.pem
settings:
database_flags:
- name: log_temp_files
value: 1
tier: db-custom-1-3840
state: present
The first setting records files of 1 KB or larger.
After
- name: Cloud SQL 인스턴스 생성
google.cloud.gcp_sql_instance:
auth_kind: serviceaccount
database_version: POSTGRES_13
name: "{{ resource_name }}-2"
project: test_project
region: us-central1
service_account_file: /tmp/auth.pem
settings:
database_flags:
- name: log_temp_files
value: 0
tier: db-custom-1-3840
state: present
The second also records files smaller than 1 KB.