postgresql commit관련 문의드립니다. 0 1 2,060

by silverg [DB 기타] postgresql commit [2023.10.13 10:48:23]


안녕하세요 현재 postgresql dbms 사용하고있으며

환경은 OLTP 환경입니다.

 

트랜잭션이 완료되면 commit을 찍는데 select에는 commit명령이 따로 발생하지 않는건지

궁금해 문의드립니다!!

by pajama [2023.10.13 17:13:28]

PostgreSQL 문서에는 SELECT를 포함한 모든 SQL이 트랜잭션 (BEGIN ~ COMMIT) 내에서 실행된다고 하네요

 

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.

https://www.postgresql.org/docs/13/tutorial-transactions.html

 

 

pg_stat_database에서 xact_commit 값을 참고하시면 좋을 듯 합니다.

 

postgres=# select xact_commit from pg_stat_database where datname='postgres'
postgres-# ;
 xact_commit
-------------
      850753
(1 row)

postgres=# select xact_commit from pg_stat_database where datname='postgres'
;
 xact_commit
-------------
      850754
(1 row)

 


댓글등록
SQL문을 포맷에 맞게(깔끔하게) 등록하려면 code() 버튼을 클릭하여 작성 하시면 됩니다.
로그인 사용자만 댓글을 작성 할 수 있습니다. 로그인, 회원가입