SQL更新查询
我们将主键与
Access 中的字段 no、id 和 groupno 组合在一起,这是一个 WHERE 条件,例如 WHERE no = '' & groupno = ''
执行速度更快,但同样会减慢 SQL 中的更新速度。
一旦我们提供了 no & 的单独索引, groupno,会更快吗?
如果我们提供具有 3 个三个字段的主键并且没有基于这些字段的单独索引,它是否会将其视为组合键?
We have combined primary key with fields no, id and groupno
From Access, a WHERE condition such as WHERE no = '' & groupno = ''
executes faster while the same thing slows down updates in SQL.
Once we have provided individual index of no & groupno, will it be faster?
Does it consider it as a combined key if we provide primary key with 3 three fields and no individual index based on those fields?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一般来说,从快速完成过滤的角度来看,它会更喜欢单个索引(您为最左边的字段提供值)。
此外,您在更新中接触索引字段的次数越多,则花费在索引维护上的时间就越多。
请注意不要过多地了解对小数据集执行某项操作的时间安排 - 您可以轻松地查看连接开销。
我建议通过查询分析器/SQL Server Management Studio 查看查询计划 - 这将允许您查看其实际使用的索引,这样您就不会在黑暗中进行探测。
In general it's going to prefer a single index (with you providing values for the left most fields) from the point of view of getting the filtering done quickly.
Also the more you touch indexed fields in an update, the more time is going to be spent doing index mainenance.
Be careful about reading too much into timings of doing sometthing once for small datasets - you could easily be looking at connection overhead instead.
I suggest having a look in the query plan via Query Analyzer/SQL Server Management Studio - this will allow you to see which index its actually really using, so you're not probing in the dark.
什么版本的 SQL? 索引不会加快查询 NULL 值的速度,因为对于 Oracle 来说,这些值不会放置在索引中。
What version of SQL? An index will not speed up querying NULL values as these are not placed in indexes, for Oracle any way.