Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show full text of running queries in PostgreSQL

Tags:

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?

like image 882
Pooria Kaviani Avatar asked Dec 01 '13 20:12

Pooria Kaviani


People also ask

How do I use full text search in PostgreSQL?

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.

How do you show the currently running queries?

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.

How do you check which query is running in Postgres?

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.

Is it possible to get a history of queries made in Postgres?

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.


1 Answers

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.

like image 199
Jerzy Pawlikowski Avatar answered Sep 22 '22 00:09

Jerzy Pawlikowski