Google Cloud SQL - 破译 Postgres 日志并查看临时日志文件
Google Cloud SQL - Deciphering Postgres log & viewing temporary log file
我在 Google 云 SQL 上有一个 Postgres 实例 运行。我在破译在线消息时遇到了一些问题 "Logs Viewer"。
我收到很多 "info" 级别的消息,看起来像这样,一遍又一遍地重复。
[i] 2019-06-12 16:19:05.376 MDT [119402]: [2-1] db=cleanchemidata,user=cleanchemiadmin STATEMENT: SELECT MAX("cc_systemdataview"."time_stamp") AS "time_stamp__max" FROM "cc_systemdataview" WHERE "cc_systemdataview"."job_id" = 72
[i] 2019-06-12 16:19:06.213 MDT [119401]: [1-1] db=cleanchemidata,user=cleanchemiadmin LOG: temporary file: path "base/pgsql_tmp/pgsql_tmp119401.0", size 38330368
我创建了那个用户和数据库,并且我知道我的应用程序为什么要做出那个 select 语句。
我 不 理解为什么这个 select 语句被打印在日志中(但我的应用程序中没有其他 SQL 语句)。看起来不像是错误?
位于路径 "base/pgsql_tmp/pgsql_tmp119401.0" 的临时日志文件可能有答案,但我不知道如何访问它。我已尝试打开 "cloud shell" 并浏览文件系统,但找不到此 "base" 或 "pgsql_tmp" 文件夹或任何日志文件。
关于显示此 STATEMENT
消息或如何访问此临时日志文件的任何想法?
根据以下 link 用于 PostgreSQL 性能监控:
This log event is emitted when a temporary file was written, used as
part of normal operations, and then deleted again.
Commonly you would see this when a query could not allocate enough
memory due to work_mem restrictions, and had to use a file on disk to
perform a sort or hash operation.
您可以在提供的 link 中找到更多详细信息以及要采取的建议操作。
我不熟悉您的数据库约束,但我会考虑优化上述查询,因为不使用临时文件的查询通常性能更好。
至于访问日志文件,很遗憾,您目前无法查看临时文件,因为,Cloud SQL is a fully-managed service. The only way to visualize the logs is through Stackdriver logging as described here。
请务必了解 Cloud Shell 本身是一个临时 VM 实例。其主要目的是让您无需安装 Google Cloud SDK 即可轻松管理您的项目和资源。它的内容与 Cloud SQL 的实例 file-system 无关,因此您看不到您提到的目录。
我在 Google 云 SQL 上有一个 Postgres 实例 运行。我在破译在线消息时遇到了一些问题 "Logs Viewer"。
我收到很多 "info" 级别的消息,看起来像这样,一遍又一遍地重复。
[i] 2019-06-12 16:19:05.376 MDT [119402]: [2-1] db=cleanchemidata,user=cleanchemiadmin STATEMENT: SELECT MAX("cc_systemdataview"."time_stamp") AS "time_stamp__max" FROM "cc_systemdataview" WHERE "cc_systemdataview"."job_id" = 72
[i] 2019-06-12 16:19:06.213 MDT [119401]: [1-1] db=cleanchemidata,user=cleanchemiadmin LOG: temporary file: path "base/pgsql_tmp/pgsql_tmp119401.0", size 38330368
我创建了那个用户和数据库,并且我知道我的应用程序为什么要做出那个 select 语句。
我 不 理解为什么这个 select 语句被打印在日志中(但我的应用程序中没有其他 SQL 语句)。看起来不像是错误?
位于路径 "base/pgsql_tmp/pgsql_tmp119401.0" 的临时日志文件可能有答案,但我不知道如何访问它。我已尝试打开 "cloud shell" 并浏览文件系统,但找不到此 "base" 或 "pgsql_tmp" 文件夹或任何日志文件。
关于显示此 STATEMENT
消息或如何访问此临时日志文件的任何想法?
根据以下 link 用于 PostgreSQL 性能监控:
This log event is emitted when a temporary file was written, used as part of normal operations, and then deleted again.
Commonly you would see this when a query could not allocate enough memory due to work_mem restrictions, and had to use a file on disk to perform a sort or hash operation.
您可以在提供的 link 中找到更多详细信息以及要采取的建议操作。
我不熟悉您的数据库约束,但我会考虑优化上述查询,因为不使用临时文件的查询通常性能更好。
至于访问日志文件,很遗憾,您目前无法查看临时文件,因为,Cloud SQL is a fully-managed service. The only way to visualize the logs is through Stackdriver logging as described here。
请务必了解 Cloud Shell 本身是一个临时 VM 实例。其主要目的是让您无需安装 Google Cloud SDK 即可轻松管理您的项目和资源。它的内容与 Cloud SQL 的实例 file-system 无关,因此您看不到您提到的目录。