There is no history in the database itself, if you use psql, you can use "\ s" to see your command history there.
You can receive future requests or other types of operations in the log files by setting log_statement in the postgresql.conf file. Instead, you most likely want a log_min_duration_statement , which, if you set it to 0, will log all requests and their duration in the logs. This can be useful after your applications run live, if you set a higher value, you will see only long queries that can be useful for optimization (you can run EXPLAIN ANALYZE on the queries you find there to find out why are they slow).
Another useful thing to know in this area is that if you run psql and say "\ timing", it will show how long each statement will take after that. Therefore, if you have a sql file that looks like this:
\timing select 1;
You can run it with the correct flags and see how each statement alternates with how much time it took. Here's what the result looks like:
$ psql -ef test.sql Timing is on. select 1; ?column? ---------- 1 (1 row) Time: 1.196 ms
This is convenient because you do not need to be the superuser of the database to use it, unlike modifying the configuration file, and it is easier to use if you are developing new code and want to test it.
Greg Smith Oct 06 '09 at 4:37 2009-10-06 04:37
source share