SQL 显示 PostgreSQL 中正在运行的查询的全文

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20316579/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 23:19:08  来源:igfitidea点击:

Show full text of running queries in PostgreSQL

sqlpostgresql

提问by Pooria Kaviani

I want to see the full text of running queries in PostgreSQL.

我想看看在PostgreSQL中运行查询的全文。

When I run this command SELECT procpid,current_query FROM pg_stat_activity ORDER BY procpid;in dbshell it shows running queries, but for long queries, it does not show complete query.

当我SELECT procpid,current_query FROM pg_stat_activity ORDER BY procpid;在 dbshel​​l 中运行此命令时,它会显示正在运行的查询,但对于长查询,它不会显示完整的查询。

For example, if a query has a long text, it does not show the complete text of the query, it only shows 1024 characters of the query and not more.

例如,如果一个查询有一个长文本,它不会显示查询的完整文本,它只显示查询的 1024 个字符而不是更多。

I want to know is there any way to show the complete query?

我想知道有没有办法显示完整的查询?

采纳答案by Jerzy Pawlikowski

There is a line in file postgresql.conf:

文件 postgresql.conf 中有一行:

track_activity_query_size = 1024

After increasing this variable you will get more characters. Tested on postgresql 9.1. Changing above line requires restarting server.

增加此变量后,您将获得更多字符。在 postgresql 9.1 上测试。更改以上行需要重新启动服务器。