PostgreSQL相当于SQLServer的NoLock提示 [英] PostgreSQL Equivalent of SQLServer's NoLock Hint
问题描述
在SQLServer中,您可以使用语法(nolock)来确保查询不会锁定表或不会被锁定同一表的其他查询阻止。
例如
In SQLServer, you can use syntax "(nolock)" to ensure the query doesn't lock the table or isn't blocked by other queries locking the same table. e.g.
SELECT * FROM mytable (nolock) WHERE id = blah
Postgres中的等效语法是什么?我在PG中找到了一些有关表锁定的文档( http://www.postgresql .org / docs / 8.1 / interactive / sql-lock.html ),但似乎都针对如何锁定表,而不是确保其未锁定 。
What's the equivalent syntax in Postgres? I found some documentation on table locking in PG (http://www.postgresql.org/docs/8.1/interactive/sql-lock.html), but it all seems geared at how to lock a table, not ensure it's not locked.
推荐答案
SELECT不会锁定PostgreSQL中的任何表,除非您想要锁定:
A SELECT doesn't lock any table in PostgreSQL, unless you want a lock:
SELECT * FROM tablename FOR UPDATE;
PostgreSQL使用 MVCC 可以最大程度地减少锁争用,以便在多用户环境中实现合理的性能。读者不会与作家或其他读者发生冲突。
PostgreSQL uses MVCC to minimize lock contention in order to allow for reasonable performance in multiuser environments. Readers do not conflict with writers nor other readers.
这篇关于PostgreSQL相当于SQLServer的NoLock提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!