2

我正在开发一个小型 Web 项目,该项目需要为NumViews数据库表中的每个对象/行保留一个计数器。我担心对行的所有更新都会开始真正降低性能,无论是表的对象数增加还是站点的使用量都会增加。

如果重要的话,我将 .NET 3.5 与 MSSQL 2K5 一起使用。

有什么建议么?

提前致谢!

——乔尔


我们目前对 DB 使用情况的猜测持续达到每秒约 66 次读取。

我喜欢将计数器拆分为单独的表的想法。您是否知道任何支持它的文章或白页,或者它是每个人都会做的事情之一?:-P

此外,在更新时,数据库是锁定整个表还是锁定特定行?我会假设只是一排,但不确定。

谢谢,

--j

4

4 回答 4

1

我建议:

  1. 将行 -> 计数数据放在另一个表中(具有固定大小的列),这样您就不会为了保持计数而不断写入主表

  2. 抽象对它的访问,以便随着应用程序的增长,您可以用一些更有效的结构替换数据库表

于 2008-12-02T18:59:14.263 回答
1

Consider using a "Views" event table, write-only, that stores each view with a timestamp. No locking problems, no sweat, full audit trail at the most granular level. Little tiny records, ~ 5MM records a day?

Someone will probably want it later, and it's simple to add it now and use it. If someone wants to do analysis/mining on it, this will be useful. At that volume, I can't imagine much else to use it for.

于 2008-12-02T19:24:15.303 回答
0

我认为这可能是一个严重的问题。读取是 100% 可扩展的,但写入需要锁定,因此您在每次读取时隐式地施加锁定开销,从而将它们序列化。你知道你必须保持的读取率是多少吗?您是否查看过作为 RDBMS 的一部分可用的审计选项?

于 2008-12-02T19:03:53.003 回答
0

I'd consider doing one of the following:

  • Use a buffer within the application and batch write a set of views every time buffers gets full
  • Using a local logging file and aggregate its results in a batch load once in a while
  • Use an event system (Pub/Sub) to fire events from your application which will later be dealt with by another application (subscriber) asynchronously. Take a look at the following project
于 2008-12-10T21:51:58.637 回答