Home > Mobile >  Does Postgres log implicit transactions?
Does Postgres log implicit transactions?

Time:01-25

Postgres docs state

PostgreSQL actually treats every SQL statement as being executed within a transaction. If you do not issue a BEGIN command, then each individual statement has an implicit BEGIN and (if successful) COMMIT wrapped around it. A group of statements surrounded by BEGIN and COMMIT is sometimes called a transaction block.

SELECT statement logs aren't wrapped in BEGIN and COMMIT when I set log_statement='all' (as per How to log PostgreSQL queries?). INSERT logs, on the other hand, are wrapped in BEGIN and COMMIT.

Are implicit transactions excluded from logs?

Related: Does Postgresql implicitly wrap select statements in transaction?

CodePudding user response:

Does Postgres log implicit transactions?

No.

The logs show explicit SQL statements from clients. The implicit transactions around standalone statements weren't controlled by statements, so BEGIN and COMMIT don't turn up in the logs.

  • Related