0

In my case, I have a custom forum shared among several users in asp.net and C#. I found the loading process pretty costly (several tables joined for different purposes). The users can modify and add new entries. But I don't want to load the object per user. Considering that the static variables - especially when editable- are not thread safe. I wonder what is the best practice to do so.

4

1 回答 1

2

有一个简短的答案......这个问题的答案很长。长答案可以在programmers.stackexchange.com上找到。简短的答案是我将在这里给你的。

我建议(非常有条件,因为我不知道查询的性质)您在数据库中为该复杂连接创建一个视图,原因是数据库将为您缓存视图并在每次查询触及的表被更新。这意味着您只需对该视图进行查询,而不是您现在正在执行的非常复杂的查询。请注意,这是一个短期解决方案,如果您的用户数量增加,这可能会导致您的数据库开始占用 CPU 和内存。

于 2013-06-26T19:17:18.220 回答