- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
在数据库中,我们不希望在修改该表中的行时删除该表。根据我的理解,表上的读锁+在表中写入行时的行上的写锁应该足够了(基于删除表时需要写锁),为什么在这种情况下我们需要意向锁?似乎很多数据库都使用意向锁,这让我很困惑。我认为 pthread_rwlock 应该足够了。
最佳答案
我读了here它们只为性能而存在。想象一下,您想要删除一个表,但您必须检查每一行是否已锁定 - 这将非常耗时,并且您必须锁定您检查的每一行。
引用博客文章:
From a technical perspective the Intent Locks are not really needed by SQL Server. They have to do with performance optimization. Let’s have a look on that in more detail. With an Intent Lock SQL Server just indicates at a higher level within the Lock Hierarchy that you have acquired a Lock somewhere else. A Intent Shared Lock tells SQL Server that there is a Shared Lock somewhere else. A Intent Update or Intent Exclusive Lock does the same, but this time SQL Server knows that there is an Update Lock or an Exclusive Lock somewhere. It is just an indication, nothing more.
But how does that indication help SQL Server with performance optimization? Imagine you want to acquire an Exclusive Lock at the table level. In that case, SQL Server has to know if there is an incompatible lock (like a Shared or Update Lock) somewhere else on a record. Without Intent Locks SQL Server would have to check every record to see if an incompatible lock has been granted.
But with an Intent Shared Lock on the table level, SQL Server knows immediately that a Shared Lock has been granted somewhere else, and therefore an Exclusive Lock can’t be granted at the table level. That’s the whole reason why Intent Locks exist in SQL Server: to allow efficient checking if an incompatible lock exists somewhere within the Lock Hierarchy. Quite easy, isn’t it?
关于database - 为什么我们需要意向锁?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33166066/
是否可以将我的应用程序的用户从我的 Android 应用程序重定向到我在最近发布的 Pebble 商店中的表盘条目? 从技术上讲,我想知道新的 2.0.0 Pebble 应用程序是否捕获任何 URI
是否可以启动 genius scan(或类似的东西,只要它是免费的)作为获取其图片的 Intent ?或者让它出现在“打开方式”对话框中?我已经尝试联系制造商并用谷歌搜索了这个问题。 最佳答案 更新
我是一名优秀的程序员,十分优秀!