admin管理员组文章数量:1415697
I recently did some work around wrapping a set of select
queries into a transaction. I was looking at both Repeatable Read and Serializable/Snapshot isolation.
Postgres has done some work on performance of deferrable read-only queries (Serializable Snapshot Isolation (SSI) and Predicate Locking). An earlier stack overflow question on this topic is Does PostgreSQL run some performance optimizations for read-only transactions .
The problem that I am trying to solve is figuring out the relative impact of the two. The previous stack overflow question had discussion around the optimization, but nothing on how to figure out which approach is better. Metrics are good, but it's hard to measure this under sufficient load to demonstrate the impact of locking.
- Is there something akin to query plans for locking?
- If not, what should I be looking at?
I recently did some work around wrapping a set of select
queries into a transaction. I was looking at both Repeatable Read and Serializable/Snapshot isolation.
Postgres has done some work on performance of deferrable read-only queries (Serializable Snapshot Isolation (SSI) and Predicate Locking). An earlier stack overflow question on this topic is Does PostgreSQL run some performance optimizations for read-only transactions .
The problem that I am trying to solve is figuring out the relative impact of the two. The previous stack overflow question had discussion around the optimization, but nothing on how to figure out which approach is better. Metrics are good, but it's hard to measure this under sufficient load to demonstrate the impact of locking.
- Is there something akin to query plans for locking?
- If not, what should I be looking at?
1 Answer
Reset to default 1The REPEATABLE READ
isolation level has even less direct impact on performance than the default READ COMMITTED
isolation level. The reason for that is that with READ COMMITTED
, every statement has to take a snapshot of the database, while with REPEATABLE READ
, only the first statement in a transaction takes a snapshot, which is retained for the whole transaction.
The only consideration is that long read-only REPEATABLE READ
transactions (unlike READ COMMITTED
) block the progress of autovacuum, which can lead to table bloat, which in turn can affect performance. So make sure that you don't have long-running transactions.
SERIALIZABLE
will incur a performance cost because of the additional predicate locks.
Don't fet that with both REPEATABLE READ
and SERIALIZABLE
you can get serialization errors, which require you to repeat transactions. Having to repeat transactions frequently can also affect performance.
版权声明:本文标题:postgresql - Performancescalability difference between different transaction isolation levels - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745238818a2649199.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
pg_locks
. Here's a recent thread about problematic locking inserializable
with a demo showing those locks. – Zegarek Commented Feb 4 at 19:59log_lock_waits
and adjustdeadlock_timeout
to collect some stats about how much your queries have to wait around in queues. – Zegarek Commented Feb 4 at 20:54