严重碎片索引 - SQL Server 2005

发布于 2024-09-10 05:24:40 字数 275 浏览 4 评论 0原文

我最近继承了一个维护不善的生产数据库,其索引碎片严重(大多数索引碎片超过 80%)。我向经理请求停机以执行索引重建,但不幸的是目前不允许停机。如果在线索引重组也不是选项,我可以执行以下操作吗?

  1. 将新的生产副本恢复到测试实例
  2. 重建索引,更新统计信息
  3. 从测试实例覆盖产品数据库
  4. 应用事务日志以获取数据库。

上述方法虽然也需要停机时间,但相对较少。我想知道是否有人可以做到这一点,或者我只是很愚蠢:) 请告知

RK

I recently inherited a poorly maintained production database with heavily fragmented indexes (most of the indexes with more than 80% fragmented). I requested downtime with my manager to perform Index rebuild, but unfortunately downtime is not allowed at the moment. If online Index reorganize too is not option, can I do the following?

  1. Restore a fresh production copy to a test instance
  2. Rebuild Indexes, update statistics
  3. Overwrite the prod database from test instance
  4. Apply transaction logs to get the database.

Though the above method too requires downtime, but its relatively less. I wanted to know whether one can do this or I am just being stupid :) Please advise

RK

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

终难愈 2024-09-17 05:24:40

如果应用程序的大部分访问是通过查找进行的,那么碎片就不是问题。否则,我会尝试找到一些时间,使索引重建的影响最小,并通过计划的作业来完成。当然,该应用程序不会 24/7/365 运行且维护不善,公司也没有预料到会出现一些问题。 (他们会更换汽车的机油吗?)

就您的 4 步解决方案而言,将表复制到另一个数据库,重建索引,然后将其复制回来,除了重建现有索引之外,不会完成任何其他任务。无论如何,在将其复制回来时,索引都会重建,因此只需尝试一次安排几个表,直到完成所有操作。

祝你好运。

If most of the application's access is via seeks, then the fragmentation is not a problem. Otherwise I'd try to find some time in which the index rebuild will have minimal effect, and do it via a scheduled job. Surely the application isn't running 24/7/365 with poor maintenance, without the company expecting some problem to occur. (Do they change the oil on their cars?)

As far as your 4 step solution, copying the table to another database, rebuilding the index, and copying it back won't accomplish anything more than just rebuilding the existing index. On copying it back the index is rebuilt anyway, so just try and schedule a couple of tables at a time, until you get everything done.

Good luck.

旧瑾黎汐 2024-09-17 05:24:40

SQL Server 2005 有 在线索引重建(即非阻塞)。

否则,它永远不会离线(即数据库或服务器离线),但在正在重建的表/索引上有独占锁。

SQL Server 2005 has online index rebuilds (that is, non-blocking).

Otherwise, it's never offline (that is, database or server off line) but does have an exclusive locks on the table/index being rebuilt.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文