Lots of "COMMIT;" in the PostgreSQL log of slow queries
postgresql, ruby-on-rails
Solution
`COMMIT` is perfectly valid statement which purpose is to commit currently pending transaction. Because of nature of what it really does - making sure that data is really flushed to disk, it is likely to take most of the time.
How can you make your app work faster? Right now, it is likely that your code is using so called auto-commit mode - that is, every statement is implicitlly `COMMIT`'ted. If you explicitly wrap bigger blocks into `BEGIN TRANSACTION;` ... `COMMIT;` blocks, you will make your app work much faster and reduce number of commits. Good luck!
Problem
I am trying to optimize the PostgreSQL 9.1 database for a Rails app I am developing. In postgresql.conf I have set ``` log_min_duration_statement = 200 ``` I then use PgBadger to analyze the log file. The statement which, by far, takes up most of the time is: ``` COMMIT; ``` I get no more information than this and I am very confused as to what statement this is. Does anyone know what I can do to get more detailed information about the COMMIT queries? All other queries show the variables used in the statement, SELECT, UPDATE etc. But not the COMMIT queries.