postgresql pg_stat_activity 中的查询被截断?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1135266/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Queries in pg_stat_activity are truncated?
提问by ibz
I'm using SELECT current_query FROM pg_stat_activity;
to see the currently executing queries, but I noticed that the query is truncated. Is there any workaround or any other way to see the currently executing queries?
我正在使用SELECT current_query FROM pg_stat_activity;
查看当前正在执行的查询,但我注意到查询被截断了。是否有任何解决方法或任何其他方式来查看当前正在执行的查询?
回答by Magnus Hagander
PostgreSQL 8.4 adds the parameter "track_activity_query_size
". The value will still be truncated, but you can control at what length.
PostgreSQL 8.4 增加了参数“ track_activity_query_size
”。该值仍将被截断,但您可以控制长度。
回答by gregn
ALTER SYSTEM SET track_activity_query_size = 16384;
You will still need to restart the service for that to take effect
您仍然需要重新启动服务才能生效
回答by Tim Kane
An alternative in the extreme case is to use the gdb debugger to attach to the process and print out the query.
极端情况下的替代方法是使用 gdb 调试器附加到进程并打印出查询。
gdb [path_to_postgres] [pid]
printf "%s\n", debug_query_string
回答by Tim Kane
you can just enable statement logging in postgresql (log_statement), and check the logs.
您可以在 postgresql (log_statement) 中启用语句日志记录,并检查日志。
回答by hilsenrat
If you run a Cloud SQL instance, you can configure track_activity_query_size
in Edit Instance --> Flags
section.
如果您运行 Cloud SQL 实例,则可以track_activity_query_size
在Edit Instance --> Flags
部分进行配置。
I personally set it to 32786
.
我个人设置为32786
.