如何跟踪查询缓存的改进?

发布于 2024-09-01 03:49:17 字数 143 浏览 6 评论 0原文

我正在参数化我的网络应用程序的临时 sql。因此,我预计查询计划缓存会减小大小并具有更高的命中率。也许其他重要指标也会得到改善。

我可以使用 perfmon 来跟踪这个吗?如果是这样,我应该使用什么计数器?如果不是 perfmon,我如何报告此更改的影响?

I am parameterizing my web app's ad hoc sql. As a result, I expect the query plan cache to reduce in size and have a higher hit ratio. Perhaps even other important metrics will be improved.

Could I use perfmon to track this? If so, what counters should I use? If not perfmon, how could I report on the impact of this change?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

薄暮涼年 2024-09-08 03:49:17

SQL Server,计划缓存对象

缓存命中率缓存命中与查找之间的比率。
缓存对象计数 缓存中的缓存对象数量。
缓存页 缓存对象使用的 8 KB 页面数。
正在使用的缓存对象正在使用的缓存对象数量。

还有 sys.dm_os_memory_clerkssys.dm_os_memory_cache_counters 将提供有关内存分配(一般)和 SQL 的信息缓存(一般情况)。您将对计划缓存内存管理员的分配感兴趣。

最后是执行 DMV:sys.dm_exec_query_statssys.dm_exec_cached_plans

这些计数器和 DMV 应满足您的需要,有关更多详细信息,请参阅执行计划缓存和重用

SQL Server, Plan Cache Object

Cache Hit Ratio Ratio between cache hits and lookups.
Cache Object Counts Number of cache objects in the cache.
Cache Pages Number of 8-kilobyte (KB) pages used by cache objects.
Cache Objects in use Number of cache objects in use.

Also sys.dm_os_memory_clerks and sys.dm_os_memory_cache_counters will give information about memory allocations (in general) and SQL caches (in general). You'll be interested in allocation for the plan cache memory clerk.

And finally there are the execution DMVs: sys.dm_exec_query_stats and sys.dm_exec_cached_plans.

These counters and DMVs should cover what you need, for more details see Execution Plan Caching and Reuse.

没有伤那来痛 2024-09-08 03:49:17

您可以使用 SQL Server Profiler。创建新跟踪,并捕获 TSQL->Exec Ready Sql 和 TSQL->Prepare Sql 事件。前者会告诉您何时重用查询计划,后者何时重新生成计划。

您也可以在事件的 SP 类别下对存储过程执行相同的操作。

You can use SQL Server Profiler. Create a new trace, and capture the TSQL->Exec Prepared Sql and TSQL->Prepare Sql events. The former will tell you when it's reusing a query plan, the latter when it is regenerating the plan.

You can do the same for Stored Procedures as well, under the SP category of events.

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