在 Linq to SQL 中如何防止编译查询重新编译
我正在使用编译查询。正如预期的那样,它们第一次需要额外的时间来编译,但我还注意到它们在大约 30 分钟没有被调用后重新编译。
是否可以控制查询何时重新编译或完全阻止它们重新编译?
仅供参考:我注意到的性能差异的一个例子是,我的一个查询在未编译时需要 6 秒,而编译时则需要不到 10 秒,因此如果我可以控制或阻止查询重新编译,将会产生巨大的差异。
任何帮助将不胜感激。
I am using compiled queries. As expected they take extra time to compile for the first time however what I have also noticed is that they recompile after not being called for approximately 30 minutes.
Is it possible to control when queries recompile or prevent them for recompiling altogether?
FYI: An example of the performance difference I notice is that one of my queries take 6 seconds when uncompiled compared to less than 10 seconds when compiled, so it's going to make a huge difference if I can control or prevent queries from recompiling.
Any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您不使用编译查询并使用 linq 编写查询,那么第一次在 Sql Engine 上执行查询时,将创建一个执行计划,然后 sql server 使用该执行计划
if you not using compiled query and write your query using linq,then in first time your query execute on Sql Engine an execution plan will created and then sql server using that execution plan