PostgreSQL10.0preview功能增強-序列隔離級別預加鎖閾值可控
標籤
PostgreSQL , 10.0 , 序列隔離級別 , max_pred_locks_per_relation , 預加鎖
背景
PostgreSQL 序列隔離級別中一個重要的概念是預加鎖,在事務結束時,檢測預加鎖是否衝突。
10.0增加了三個控制引數,可以控制預加鎖的上限。避免記憶體過度使用。
1. 控制每個事務的物件預加鎖數量。
max_pred_locks_per_transaction (integer)
The shared predicate lock table tracks locks on max_pred_locks_per_transaction * (max_connections + max_prepared_transactions) objects (e.g., tables);
hence, no more than this many distinct objects can be locked at any one time.
This parameter controls the average number of object locks allocated for each transaction;
individual transactions can lock more objects as long as the locks of all transactions fit in the lock table.
This is not the number of rows that can be locked; that value is unlimited.
The default, 64, has generally been sufficient in testing, but you might need to raise this value if you have clients that touch many different tables in a single serializable transaction.
This parameter can only be set at server start.
2. 當單個物件的行或者頁預加鎖數量達到閾值時,升級為物件預加鎖。減少記憶體開銷。
max_pred_locks_per_relation (integer)
This controls how many pages or tuples of a single relation can be predicate-locked before the lock is promoted to covering the whole relation.
Values greater than or equal to zero mean an absolute limit, while negative values mean max_pred_locks_per_transaction divided by the absolute value of this setting.
The default is -2, which keeps the behaviour from previous versions of PostgreSQL.
This parameter can only be set in the postgresql.conf file or on the server command line.
3. 當單個頁內多少條記錄被加預加鎖時,升級為頁預加鎖。減少記憶體開銷。
max_pred_locks_per_page (integer)
This controls how many rows on a single page can be predicate-locked before the lock is promoted to covering the whole page.
The default is 2. This parameter can only be set in the postgresql.conf file or on the server command line.
關於序列隔離級別的概念,您可以參考
《PostgreSQL SERIALIZABLE ISOLATION LEVEL introduce》
patch 資訊如下
Add GUCs for predicate lock promotion thresholds.
author Kevin Grittner <kgrittn@postgresql.org>
Sat, 8 Apr 2017 10:38:05 +0800 (21:38 -0500)
committer Kevin Grittner <kgrittn@postgresql.org>
Sat, 8 Apr 2017 10:38:05 +0800 (21:38 -0500)
commit c63172d60f242ad3581c83723a5b315bbe547a0e
tree 0a98686f027aacecb01869bfb269ebd486ea3ba7 tree | snapshot
parent 9c7f5229ad68d7e0e4dd149e3f80257893e404d4 commit | diff
Add GUCs for predicate lock promotion thresholds.
Defaults match the fixed behavior of prior releases, but now DBAs
have better options to tune serializable workloads.
It might be nice to be able to set this per relation, but that part
will need to wait for another release.
Author: Dagfinn Ilmari Mannsåker
這個patch的討論,詳見郵件組,本文末尾URL。
PostgreSQL社群的作風非常嚴謹,一個patch可能在郵件組中討論幾個月甚至幾年,根據大家的意見反覆的修正,patch合併到master已經非常成熟,所以PostgreSQL的穩定性也是遠近聞名的。
參考
相關文章
- RR與RC隔離級別下MySQL不同的加鎖解鎖方式MySql
- mysql事務隔離級別和鎖MySql
- Mysql鎖與事務隔離級別MySql
- Fescar鎖和隔離級別的理解
- Postgresql 的預設隔離級別SQL
- MySQL資料庫事務各隔離級別加鎖情況--read uncommittMySql資料庫MIT
- MySQL資料庫事務各隔離級別加鎖情況--Repeatable ReaMySql資料庫
- Mysql事務隔離級別與鎖機制MySql
- MySQL資料庫引擎、事務隔離級別、鎖MySql資料庫
- 事務隔離(二):基於加鎖方式的事務隔離原理
- MySQL的隔離級別MySql
- 詳解Mysql事務隔離級別與鎖機制MySql
- 資料庫事務隔離級別的深坑:預設值應修改為SERIALIZABLE資料庫
- [Mysql]事務/隔離級別MySql
- 資料庫隔離級別資料庫
- MySQL事務隔離級別MySql
- Mariadb之事務隔離級別
- 事務、特性、隔離級別
- MySQL 事務隔離級別MySql
- PostgreSQL事務隔離級別SQL
- MySQL的事務預設隔離級別是什麼MySql
- MySQL InnoDB中的事務隔離級別和鎖的關係MySql
- 理解MySQL事務隔離級別MySql
- MySQL 的隔離級別 自理解MySql
- 事務四種隔離級別
- MySQL的事務隔離級別MySql
- MySQL事務的隔離級別MySql
- MySQL 事務的隔離級別及鎖操作的一點點演示MySql
- 【每日鮮蘑】資料庫隔離級別、髒讀、幻讀、鎖等資料庫
- MySQL之事務隔離級別和MVCCMySqlMVC
- 事務的隔離級別與MVCCMVC
- mysql如何修改事務隔離級別MySql
- 啥是 MySQL 事務隔離級別?MySql
- 事務系統的隔離級別
- 理解mysql的事務隔離級別MySql
- 事務的四種隔離級別
- 事務ACID特性與隔離級別
- Mysql 四種事務隔離級別MySql
- 淺析MySQL InnoDB的隔離級別MySql