SQL Server 2005 数据库引擎优化顾问是否会“调整”临时表?
我正在尝试使用数据库引擎优化顾问来调整我的数据库。从它记录的评论(运行整个周末后,仅分析了 40%)来看,DTA 似乎无法调整临时表上的操作。事实真的是这样吗?
I'm attempting to use Database Engine Tuning Advisor to tune my database. From the comments it's logging (it's just 40% into the analysis, after running all weekend) it appears that DTA is not capable of tuning operations on Temporary tables. Is that in fact the case?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不可以。因为为了将索引应用于临时临时表,您必须将索引添加到使用临时表的脚本中。它不能仅仅作为“一劳永逸”操作应用于非永久表。
您可以做的是在数据库中创建一个同名的真实表,并从脚本中删除临时表的创建并替换为 TRUNCATE TABLE。如果您创建此表,然后对其执行操作,DTA 将建议为永久表建立索引。然后,您可以编写这些推荐索引的脚本,并将它们添加到脚本中的临时表中。
另外:请注意,虽然 DTA 在大多数情况下做得很好,但它并不总是正确的......
No. Because in order to apply an index to a transient temporary table you would have to add the index to the script that used the temporary table. It can't just be applied to a non-permanent table as a set-and-forget operation.
What you can do is create a real table with the same name in your database and remove the creation of the temp table from scripts and replace with TRUNCATE TABLE. If you create this table, and then perform actions against it, the DTA will recommend indexing for the permanent table. You then script these recommended indexes, and add them to the temp table in your script.
Also: be aware that while the DTA does a pretty good job in most cases, it doesn't always get it right...