在 Linq to SQL 中如何防止编译查询重新编译

发布于 2024-11-15 07:35:40 字数 215 浏览 7 评论 0原文

我正在使用编译查询。正如预期的那样,它们第一次需要额外的时间来编译,但我还注意到它们在大约 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

以酷 2024-11-22 07:35:40

如果您不使用编译查询并使用 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文