🐘 PostgreSQL Intermediate

What are isolation levels in PostgreSQL?

Answer

PostgreSQL supports four transaction isolation levels (SQL standard). READ UNCOMMITTED: PostgreSQL treats this as READ COMMITTED — dirty reads never occur. READ COMMITTED (default): a query sees only committed data at the moment the query started; different statements in the same transaction may see different data. REPEATABLE READ: all queries in a transaction see data as of the transaction start; prevents non-repeatable reads; may get serialization errors. SERIALIZABLE: strictest level — transactions appear to execute sequentially; uses SSI (Serializable Snapshot Isolation) in PostgreSQL; may get serialization failures requiring retry. Set per transaction: SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;. Choose the lowest isolation level that satisfies correctness requirements.