如何监视 Gen2 缓存How to monitor the Gen2 cache

Gen2 存储体系结构自动将最常查询的列存储段归类到特定的缓存中,该缓存位于基于 NVMe 且专为 Gen2 数据仓库设计的 SSD 中。The Gen2 storage architecture automatically tiers your most frequently queried columnstore segments in a cache residing on NVMe based SSDs designed for Gen2 data warehouses. 如果查询检索驻留在缓存中的段,则可提高性能。Greater performance is realized when your queries retrieve segments that are residing in the cache. 本文介绍如何监视和排查查询性能下降的问题,只需确定工作负荷是否在充分利用 Gen2 缓存即可。This article describes how to monitor and troubleshoot slow query performance by determining whether your workload is optimally leveraging the Gen2 cache.

使用 Azure 门户进行故障排除Troubleshoot using the Azure portal

可以使用 Azure Monitor 来查看 Gen2 缓存指标,以便排查查询性能问题。You can use Azure Monitor to view Gen2 cache metrics to troubleshoot query performance. 首先转到 Azure 门户,然后单击“监视”:First go to the Azure portal and click on Monitor:

Azure Monitor

选择指标按钮,填写数据仓库的“订阅”、“资源组”、“资源类型”和“资源名称”。Select the metrics button and fill in the Subscription, Resource group, Resource type, and Resource name of your data warehouse.

排查 Gen2 缓存问题时,关键指标是“缓存命中百分比”和“缓存使用百分比”。The key metrics for troubleshooting the Gen2 cache are Cache hit percentage and Cache used percentage. 配置 Azure 指标图表,以便显示这两个指标。Configure the Azure metric chart to display these two metrics.

缓存指标

缓存命中和使用百分比Cache hit and used percentage

下表根据缓存指标的值对场景进行了说明:The matrix below describes scenarios based on the values of the cache metrics:

缓存命中百分比高High Cache hit percentage 缓存命中百分比低Low Cache hit percentage
缓存使用百分比高High Cache used percentage 方案 1Scenario 1 方案 2Scenario 2
缓存使用百分比低Low Cache used percentage 方案 3Scenario 3 方案 4Scenario 4

场景 1: 你的缓存使用已优化。Scenario 1: You are optimally using your cache. 排查可能导致查询速度变慢的其他方面的情况。Troubleshoot other areas which may be slowing down your queries.

场景 2: 当前工作数据集不适合放置在缓存中,引发物理读取困难,导致缓存命中百分比低。Scenario 2: Your current working data set cannot fit into the cache which causes a low cache hit percentage due to physical reads. 考虑提升性能级别并重新运行工作负荷,以便填充缓存。Consider scaling up your performance level and rerun your workload to populate the cache.

场景 3: 查询运行速度慢的原因可能与缓存无关。Scenario 3: It is likely that your query is running slow due to reasons unrelated to the cache. 排查可能导致查询速度变慢的其他方面的情况。Troubleshoot other areas which may be slowing down your queries. 也可以考虑缩减实例,通过缩减缓存大小来节省成本。You can also consider scaling down your instance to reduce your cache size to save costs.

场景 4: 你使用了冷缓存,这可能是查询速度慢的原因。Scenario 4: You had a cold cache which could be the reason why your query was slow. 考虑重新运行查询,因此工作数据集现在应该位于缓存中。Consider rerunning your query as your working dataset should now be in cached.

重要说明:如果缓存命中百分比或缓存使用百分比在重新运行工作负荷后未更新,则表明工作集可能已驻留在内存中。请注意,只缓存聚集列存储表。Important: If the cache hit percentage or cache used percentage is not updating after rerunning your workload, your working set can already be residing in memory. Note only clustered columnstore tables are cached.

后续步骤Next steps

有关常规查询性能优化的详细信息,请参阅监视查询执行For more information on general query performance tuning, see Monitor query execution.