Postgresql – Ubuntu, postgresql, show whole running sql command

postgresqlUbuntu

System

Linux vm16745 3.13.0-77-generic #121-Ubuntu SMP Wed Jan 20 10:50:42 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
psql (PostgreSQL) 9.3.24

Issue

I don't know if it is right section/forum, but I will try. Is possible to show whole sql command in ps? Now, when I try

ps aux | grep postgres

it shows me only begin of command.

postgres 20211  0.0  0.9 2281708 74304 ?       Rs   09:12   0:00 postgres: shop shop_prod ::1(55623) SELECT

Thanks.

Best Answer

You would want to query the query column of pg_stat_activity with a query like

SELECT query
FROM pg_stat_activity
WHERE state = 'active';

This will show the first 1024 characters of the query.

If that is not enough, raise the track_activity_query_size parameter.