May 2019
Intermediate to advanced
600 pages
20h 46m
English
A session that is not running any query is in the idle state if it's outside of a transaction, or in the idle in transaction state if it's inside a transaction, that is, between a BEGIN and the corresponding COMMIT. Recall the Writing a script that either succeeds entirely or fails entirely recipe in Chapter 7, Database Administration, which was about how BEGIN and COMMIT can be used to wrap several commands into one transaction.
The reason to distinguish between these two states is that locks are released at the end of a transaction. Hence, an idle in transaction session is not currently doing anything, but it might be preventing other queries, including VACUUM, from accessing some tables.
Read now
Unlock full access