为什么较大的表比新的较小的表更快?
我们在 SQL Server 中有一个大表,其中有近 40.000.000 条记录。在其上运行查询需要相当长的时间。因此,我们决定将所有旧的和过时的记录保留在那里,并将可用记录移到新表中并使用新表。虽然它应该比几乎有重复计数记录的旧表更快,但有问题的结果是其他的。 尽管在旧表上运行查询需要大约 45 秒,但在具有相同结构(键和索引)和一半记录数的新表上,运行相同查询需要 30 多分钟。我们哪里有错误或遗漏了一些重要问题?
We have a large table in SQL Server with almost 40.000.000 records. it took considerable time to running queries on it. so we decided to leave all old and out of date records there and move usable records in a new table an use the new one. while it supposed to be faster than old table which have almost double count of records, the problematic result was somthing else.
although runnig a query on old table takes nigh 45 seconds,on the new table with same structure (keys and indexes) and half count of records, it takes over 30 minuts to running same query. where we have mistake or missed some important issues?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否记得从较大的表中迁移索引并在新表上重新生成统计信息?
如果没有,就从这里开始。这通常是这些情况下的问题(尤其是对于大型表)。
Did you remember to migrate the indexes from the larger table and re-generate statistics on the new table?
If not, start there. That is usually the issue in these cases (especially with large tables).