zoukankan      html  css  js  c++  java
  • PG中的事务隔离级别

    SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE;
    set default_transaction_isolation='repeatable read';
    set transaction isolation level repeatable read;
    show transaction_isolation;
     
     
    设置默认的隔离级别,缺省的为read committed.
    postgres=# set default_transaction_isolation='repeatable read';
    postgres=# show transaction_isolation;
    transaction_isolation
    -----------------------
    repeatable read
     
     
    read committed,提交读,oltp
    postgres=# show transaction_isolation;
    transaction_isolation
    -----------------------
    read committed
     
    repeatable read,可重复读,做报表
    即一个事务中,所有的select读取的结果是一样,即都读同一个时间点上的数据。
    相当于 select * from as tabName as scn=12345;
     
    要注意的有同一行,补两个事务更新,被阻塞者是repeatable read事务,那么阻塞者提交后,被阻塞者将收到如下错误:
    ERROR: could not serialize access due to concurrent update
    如果阻塞者回退执行了回退,则持有repeatable read事务的被阻塞者也不会报错。
     
    postgres=# begin;
    postgres=# set transaction isolation level repeatable read;
    postgres=# show transaction_isolation;
    transaction_isolation
    -----------------------
    repeatable read
    postgres=# commit;
    postgres=# show transaction_isolation;
    transaction_isolation
    -----------------------
    read committed
     
    串行读 SERIALIZABLE read
    严格来说,PostgreSQL在9.1之前的版本中只是实现了其中两种,即读已提交和串行读。
    在PostgreSQL v9.1的版本中提供了三种实现方式,即在原有的基础上增加了可重复读。但串行读与可重复读测试目前没有差别。
    不过使用MVCC机制实现的数据库隔离级别和传统锁机制实现的数据库的隔离级别有细微的差异。
     
     
     
     
     
     
     
     
     


  • 相关阅读:
    strace排除Linux服务器故障
    详解如何在linuxmint上用源码包安装nodejs
    linux 安装nodejs
    使用Vue实现购物车功能
    Vue项目中使用better-scroll
    vue项目中使用axios发送ajax
    在VUE的项目中使用字体图标以及Stylus
    Vue在使用组件中的一些需要记住的点
    Vue简易动画实现和使用animate.css库
    使用Vue.js进行数据绑定以及父子组件传值
  • 原文地址:https://www.cnblogs.com/laverne/p/12625695.html
Copyright © 2011-2022 走看看