I want to log each query execution time which is run in a day.
For example like this,
2012-10-01 13:23:38 STATEMENT: SELECT * FROM pg_stat_database runtime:265 ms.
Please give me some guideline.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you set
in your postgresql.conf, then you will see all statements being logged into the Postgres logfile.
If you enable
that will also print the time taken for each statement. This is off by default.
Using the
log_statementparameter you can control which type of statement you want to log (DDL, DML, …)This will produce an output like this in the logfile:
More details in the manual:
If you want a daily list, you probably want to configure the logfile to rotate on a daily basis. Again this is described in the manual.