What is query can I use for show last executed queries in DB PostgreSQL or where (files) can I find this? I use pgADMIN 3
Asked
Active
Viewed 2.1k times
5
-
Probably related: https://stackoverflow.com/questions/8208310/postgresql-how-to-see-which-queries-have-run – Oto Shavadze Sep 21 '17 at 15:55
-
1Use pg_stat_statements. Or set `log_statement = all` and use the log file. – Craig Ringer Sep 21 '17 at 15:57
2 Answers
6
For those on the command line using psql
, you can view the command history with
\s
Or print it to a file with
\s filename
See also

Suragch
- 484,302
- 314
- 1,365
- 1,393
1
See the History tab in the output pane.
You can find or change the location of the file under the File/Options...
dialog.

rd_nielsen
- 2,407
- 2
- 11
- 18
-
rd_nielsen I want to know all queries (include from remoute pcs) not only me from pgAdmin – Евгений Дружинин Sep 21 '17 at 15:47
-
As far as I know, there's no way to do that. The best approach may be to establish a discipline wherein all SQL commands are scripted, and scripts are run with a custom script executor that records the time that each statement is executed in a common logfile. – rd_nielsen Sep 21 '17 at 15:53
-
1@rd_nielsen er... `log_statement = 'all'`, or use `pg_stat_statements` – Craig Ringer Sep 21 '17 at 15:58
-