CẬP NHẬT ngày 3 tháng 4 năm 2019
Hiện có thể để ghi lại các truy vấn chậm trên các phiên bản PostgreSQL của Google Cloud SQL, hãy xem https:// cloud .google.com / sql / docs / release-Notes # april_3_2019 :
database_flags = [
{
name = "log_min_duration_statement"
value = "1000"
},
]
Sau khi bạn bật log_min_duration_statement
, bạn có thể xem nhật ký bằng cách ghi nhật ký Stackdriver. Chọn Cloud SQL Database
-> cloudsql.googleapis.com/postgres.log
và bạn sẽ thấy nhật ký như thế này.
[103402]: [9-1] db=cloudsqladmin,user=cloudsqladmin LOG: duration: 11.211 ms statement: [YOUR SQL HERE]
Tài liệu tham khảo:
- Danh sách đầy đủ các cờ được hỗ trợ (CTRL + F cho
log_min_duration_statement
): https://cloud.google.com/sql/docs / postgres / flags # postgres-l - Trình theo dõi sự cố: https://issuetracker.google.com/issues/74578509#comment54
- Tài liệu PostgreSQL: https://www.postgresql.org/docs/9.6/runtime-config-logging.html#GUC-LOG-MIN-DURATION-STATEMENT