본문 바로가기

DB/PostgreSQL

현재 설정되어 있는 트랜잭션 격리 수준(transaction isolation level)확인하기

PostgreSQL에는 3가지 트랜잭션 격리 수준이 존재한다.

READ COMMITTED

A statement can only see rows committed before it began. This is the default.


REPEATABLE READ

All statements of the current transaction can only see rows committed before the first query or data-modification statement was executed in this transaction.


SERIALIZABLE

All statements of the current transaction can only see rows committed before the first query or data-modification statement was executed in this transaction. If a pattern of reads and writes among concurrent serializable transactions would create a situation which could not have occurred for any serial (one-at-a-time) execution of those transactions, one of them will be rolled back with a serialization_failure error.

참조: SET TRANSACTION (9.3)


트랜잭션 격리수준은 SET TRANSACTION이라는 명령을 통해 할 수 있는데 현재 설정된 격리수준은 어떻게 획득할 수 있을까?

GET TRANSACTION 일까? 아니다.

다음과 같이 SELECT 명령으로 구할 수 있다.

SELECT current_setting('transaction_isolation');

출처: how to get transaction isolation level info


기본적으로 설정된 값은 "read committed"이다.


동시적인 접근이 이루어지는 상황에서는 isolate level은 중요한 이슈가 된다.

관련된 자료는 오래되었긴 하지만(2002년) PostgreSQL Concurrency Issues를 참고하면 좋을 것 같다. concurrency.pdf


물론 PostgreSQL 공식 문서중 13장 Concurrency Control을 참고하면 좋다.

'DB > PostgreSQL' 카테고리의 다른 글

PostgreSQL에서 inet이나 macaddr을 쓰는 것이 좋을까?  (0) 2014.08.07