I want to see the full text of running queries in 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.
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.
I want to know is there any way to show the complete query?
In PostgreSQL, you use two functions to perform Full Text Search. They are to_tsvector() and to_tsquery(). Let's see how they work and to use them first. to_tsvector() function breaks up the input string and creates tokens out of it, which is then used to perform Full Text Search using the to_tsquery() function.
To list running queries, we need to use the 'show processlist' command. The following is the query. mysql> SHOW processlist; The following is the output of the above query.
Identify the current activity of the session by running the following command: SELECT * FROM pg_stat_activity WHERE pid = PID; Note: Replace PID with the pid that you identified in the step 1.
There's no history in the database itself, if you're using psql you can use "\s" to see your command history there. You can get future queries or other types of operations into the log files by setting log_statement in the postgresql. conf file.
There is a line in file 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With