亚音速“保存”改进建议
[我们正在使用 ActiveRecord。]
在运行 Sql Server Profiler 时,我们注意到简单的“保存”之前有大量的数据库活动。我们发现 SubSonic 核心会遍历所有属性,并在实际保存之前将它们的值保存在字典中。
我们通常在部分类中“扩展”数据对象,其中包括一些需要数据库活动的属性。这就是额外活动发生的地方,而且据我们所知,这是不必要的。
我们更改了脚本从每个数据库列创建属性的位置,以便它现在用 [LocalData] 装饰这些属性。然后,我们更改了核心 (Extensions.Objects.ToDictionary),以在缺少此属性时跳过 GetValue。
在一项有大量保存类型数据库活动的测试中,我们看到运行时间从 21 秒下降到 2 秒,数据库活动下降了大约三分之二。
所有这一切有两个问题:1)我们是否错过了一个功能,使我们的更改变得不必要,2)如果没有,您是否知道其他一些与 ToDictionary 相关的流程现在会中断?
谢谢!
[We are using ActiveRecord.]
While running Sql Server Profiler, we noticed that a simple "Save" was preceded by a good bit of database activity. We found that the SubSonic core runs through all the properties and saves their values in a dictionary before it actually does the save.
We typically "extend" our data objects in partial classes that include some properties that require database activity. This is where the extra activity is happening, and, as far as we can tell, unnecessarily.
We changed where the script creates a property from each database column so that it now decorates these properties with [LocalData]. We then changed the core (Extensions.Objects.ToDictionary) to skip the GetValue if this attribute is missing.
In one test with a lot of save-type database activity, we saw the elapsed time drop from 21 seconds to 2, and the database activity drop by about two thirds.
There are two questions in all this is: 1) was there a feature we missed that would make our change unnecessary, and 2) if not, do you know of some other ToDictionary-related processes that will now break?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
[SubSonicIgnore] 属性会达到同样的效果吗?
Would the [SubSonicIgnore] attribute have achieved the same thing?