且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SQL Server(2005) - “已删除” DATETIME和索引

更新时间:2023-02-03 07:45:28

您是否有可能将这些死记录转移到单独的表中?例如。对于课程表,有一个 Courses_deleted 表或类似的东西,具有相同的结构。

Is there a chance you could transfer those "dead" records into a separate table? E.g. for your Courses table, have a Courses_deleted table or something like that, with an identical structure.

当你删除一条记录时,你基本上只是把它移到死表。这样,你实际的当前数据的索引保持小而且活泼....

When you "delete" a record, you basically just move it to the "dead table". That way, the index on your actual, current data stays small and zippy....

如果你需要一个聚合视图,你总是可以定义一个 Courses_View 将两个表联合在一起。

If you need to have an aggregate view, you can always define a Courses_View which unions the two tables together.

真实桌上的聚集索引应该是因为小,静态,恒定和可能,所以我肯定建议将这样的日期时间列放入其中。不是一个好主意。

Your clustered index on your real table should be as small, static and constant and possible, so I would definitely NOT recommend putting such a date time column into it. Not a good idea.

有关如何选择一个好的群集密钥以及它需要什么的绝佳信息,请查看Kimberly Tripp的博客条目:

For excellent info on how to choose a good clustering key, and what it takes, check out Kimberly Tripp's blog entries:

  • GUIDs as PRIMARY KEYs and/or the clustering key
  • The Clustered Index Debate Continues...
  • Ever-increasing clustering key - the Clustered Index Debate..........again!

Marc