ssms .net3.5

In this article, we will run through the new options added in the Query Store with SSMS v18.4.

在本文中,我们将介绍使用SSMS v18.4在查询存储中添加的新选项。

SQL Server Management Studio aka SSMS, is one of the popular SQL Server client tools for managing SQL Server and its databases. This enables database developers and administrators to configure, administer and manage SQL Server, Azure SQL Database and SQL Data Warehouse. The best part is, it is cost-free.

SQL Server Management Studio(又名SSMS )是用于管理SQL Server及其数据库的流行SQL Server客户端工具之一。 这使数据库开发人员和管理员可以配置,管理和管理SQL Server,Azure SQL数据库和SQL数据仓库。 最好的部分是,它是免费的。

下载SSMS v18.4 (Download SSMS v18.4)

Continuing its tradition to make SSMS more productive and flexible, Microsoft has released the new version of SSMS – v18.4 which is generally available. You can download it from here. The installation process is pretty straightforward. Also, I am sure most of you may already know, but it is still worth to mention for beginners that, in June 2015, Microsoft announced that future versions of SSMS would be independent of SQL Server database engine releases.

微软秉承提高SSMS生产力和灵活性的传统,发布了新版本的SSMS – v18.4,该版本已全面上市。 您可以从这里下载。 安装过程非常简单。 此外,我相信大多数人可能已经知道,但是对于初学者而言,仍然值得一提的是,Microsoft在2015年6月宣布,SSMS的未来版本将独立于SQL Server数据库引擎版本。

查询存储 (Query Store)

As a database developer, I have often run into issues where my system would slow down and I had no clear idea of what queries are waiting for the most. Starting SQL Server 2016, Microsoft introduced Query Store, which is one of the significant additions to the performance tuning tools and it helps immensely in monitoring and troubleshooting database performance.

作为数据库开发人员,我经常遇到一些问题,这些问题会导致我的系统运行缓慢,并且我不清楚哪些查询最需要等待。 从SQL Server 2016开始,Microsoft引入了Query Store ,这是性能调整工具的重要补充之一,它可以极大地帮助监视和故障排除数据库性能。

With this tool, you can capture execution plans, force a better plan and also track a range of information about query usage, CPU, memory consumption, etc. Unlike Plan Cache that stores execution plans in-memory, Query Store captures data on disk and retains all the captured information even after SQL Start restarts.

使用此工具,您可以捕获执行计划,制定更好的计划,还可以跟踪有关查询使用率,CPU,内存消耗等的一系列信息。与将执行计划存储在内存中的计划缓存不同,查询存储可以在磁盘和磁盘上捕获数据。即使重新启动SQL Start,仍保留所有捕获的信息。

If you are new to Query Store, I would recommend understanding this feature before reading this article, it is described in great detail here, SQL Server Query Store – Overview.

如果您不熟悉查询存储,建议您在阅读本文之前先了解此功能,此处将对其进行详细介绍,即《 SQL Server查询存储–概述》 。

SSMS v18.4 added a couple of GUI options in the Query Store page, making it easier and faster for Database Administrators (DBAs) to set capture policies and make changes without any piece of code. These options can be configured using T-SQL for SSMS v18.3 and lower, with this enhancement, we can configure it with a few clicks on the Query Store tab.

SSMS v18.4在“查询存储”页面中添加了几个GUI选项,使数据库管理员(DBA)可以更轻松,更快速地设置捕获策略并进行更改,而无需任何代码。 可以使用T-SQL for SSMS v18.3及更低版本来配置这些选项,通过此增强功能,我们只需单击“查询存储”选项卡就可以对其进行配置。

This enables you to modify and customize the below features in the Query Store Database Properties page itself using SSMS 18.4.

这使您可以使用SSMS 18.4在“ 查询存储数据库属性”页面本身中修改和自定义以下功能。

  1. Added Max Plans per query value (MAX_PLANS_PER_QUERY) 为每个查询值添加了最大计划数(MAX_PLANS_PER_QUERY)
  2. Added Wait Statistics Capture Mode value (WAIT_STATS_CAPTURE_MODE) 添加了“等待统计信息捕获模式”值(WAIT_STATS_CAPTURE_MODE)
  3. Added Custom policies (STALE_CAPTURE_POLICY_THRESHOLD, EXECUTION_COUNT, TOTAL_COMPILE_CPU_TIME_MS, TOTAL_EXECUTION_CPU_TIME_MS) to the Capture mode 向捕获模式添加了自定义策略(STALE_CAPTURE_POLICY_THRESHOLD,EXECUTION_COUNT,TOTAL_COMPILE_CPU_TIME_MS,TOTAL_EXECUTION_CPU_TIME_MS)

Before we go ahead and see these new GUI options with SSMS 18.4 release, let’s quickly get our environment ready.

在继续使用SSMS 18.4发行版查看这些新的GUI选项之前,让我们快速准备好环境。

前提条件和环境准备 (Pre-requisites and preparing the environment)

For this article, we need SQL Server Management Studio, (version 18.4), and access to a SQL Server instance, I am using SQL Server 2019 here. You can make use of any database in it. I have restored AdventureWorksDW2017 sample DB, so I will use it.

对于本文,我们需要SQL Server Management Studio(版本18.4)并访问SQL Server实例,我在这里使用SQL Server 2019 。 您可以使用其中的任何数据库。 我已经恢复了AdventureWorksDW2017示例数据库,因此将使用它。

为我们的数据库启用查询存储 (Enable Query Store for our database)

Query Store can be configured on an individual database and is not generally enabled for new databases by default. Let’s quickly enable it, right-click the database >> click on Properties >> select Query Store on Database Properties page >> choose Read write in the Operation Mode (Requested) drop-down >> Hit OK.

可以在单个数据库上配置查询存储,并且默认情况下通常不为新数据库启用查询存储。 让我们快速启用它,右键单击数据库 >>单击“ 属性 ” >>在“ 数据库属性”页面上选择“ 查询 存储 ” >>在“ 操作模式(请求的)”下拉列表中选择“ 读写 ” >>单击确定。

The Query Store feature is enabled for the database, AdventureWorksDW2017 as shown below.

如下所示,为数据库AdventureWorksDW2017启用了查询存储功能。

Now that the Query Store feature is enabled. Let’s move forward and look at the new GUI options added.

现在,查询存储功能已启用。 让我们继续前进,看看添加的新GUI选项。

设置每个查询的最大计划并等待统计信息捕获模式 (Setting Max Plans Per Query and Wait Statistics Capture Mode)

Max Plans Per Query property represents the maximum number of execution plans that will be stored per query by the Query Store. The default value of max plans per query is set as 200 execution plans per query. Of course, you can increase or decrease this number based on the complexity and stability of your queries. In case of a large number of different plans being generated, keep a check on the count as it takes up disk space.

每个查询的最大计划数属性表示查询存储将为每个查询存储的最大执行计划数。 每个查询的最大计划的默认值设置为每个查询200个执行计划。 当然,您可以根据查询的复杂性和稳定性来增加或减少此数字。 如果生成大量不同的计划,请检查计数,因为它占用了磁盘空间。

Wait Statistics Capture Mode option helps you control if the Query Store will capture wait statistics information. By default, this property is set as ON. With this option being enabled, you can collect wait stats data to troubleshoot performance and figure out which query is taking long and waiting.

等待统计信息捕获模式选项可帮助您控制查询存储是否将捕获等待统计信息。 默认情况下,此属性设置为ON。 启用此选项后,您可以收集等待统计数据以对性能进行故障排除,并找出哪个查询花费了长时间并等待。

Set or modify values in the “Max Plans Per Query” and “Wait Statistics Capture Mode” options in the Query Store tab as shown in the below snapshot.

如下快照所示,在“查询存储”选项卡的“每个查询的最大计划数”和“等待统计信息捕获模式”选项中设置或修改值。

Apart from configuring these options through GUI, you can enable/modify these options using T-SQL in SSMS 18.3 and below as shown below.

除了通过GUI配置这些选项之外,您还可以使用SSMS 18.3及更低版本中的T-SQL启用/修改这些选项,如下所示。

ALTER DATABASE AdventureWorksDW2017
SET QUERY_STORE (OPERATION_MODE = READ_WRITE,  MAX_PLANS_PER_QUERY = 300,WAIT_STATS_CAPTURE_MODE = OFF)

查询存储捕获​​模式 (Query Store Capture Mode )

Query Store Capture Mode lets you specify several query capture policy settings for the database you are running your queries against. We can control whether we want to capture all queries, or track only current queries or specific queries depending upon execution count and CPU consumption.

通过查询存储捕获​​模式,可以为运行查询的数据库指定几种查询捕获策略设置。 我们可以根据执行次数和CPU消耗,控制是要捕获所有查询,还是仅跟踪当前查询或特定查询。

These options come in different flavors as All, Auto, None and Custom.

这些选项具有全部,自动,无和自定义的不同样式。

  • ALL – The default value is ALL in SQL Server 2016 and SQL Server 2017, which means all queries executed against the database will be captured in the Query Store ALL – SQL Server 2016和SQL Server 2017中的默认值为ALL,这意味着对数据库执行的所有查询都将在查询存储中捕获
  • Auto – Starting SQL Server 2019, this is the default option that rules out infrequent queries with insignificant compile and execution duration 自动 -从SQL Server 2019开始,这是默认选项,可排除编译和执行时间不长的不频繁查询
  • None – Query Store stops capturing new queries, no execution plans and statistics are recorded -查询存储停止捕获新查询,不记录执行计划和统计信息
  • Custom – This is a substantial option in providing additional control for user-defined capture policies 自定义 –这是为用户定义的捕获策略提供附加控制的重要选择

On selecting Custom in the UI drop-down above, the section Query Store Capture Policy gets editable and you can customize these values.

在上方的UI下拉菜单中选择“ 自定义 ”后,“ 查询存储捕获​​策略 ”部分将变为可编辑状态,您可以自定义这些值。

查询存储捕获​​策略 (Query Store Capture Policy)

You will notice a few things in the screenshot above.

您会在上面的屏幕截图中注意到一些事情。

Execution Count (it defines the number of times, a query will be executed and its default value is 30), Stale Threshold (it accepts a range of values from 1 hour to 7 days), Total Compile CPU Time (ms) (the default value is 1000ms) and Total Execution CPU Time (ms) (it has a default value of 100ms). CPU compilation and CPU execution times help to measure processor performance and must be set carefully.

执行计数(它定义执行查询的次数,其默认值为30),陈旧阈值(可接受1到7天的值范围),总编译CPU时间(毫秒)(默认值)值是1000毫秒)和总执行CPU时间(以毫秒为单位)(默认值为100毫秒)。 CPU编译和CPU执行时间有助于衡量处理器性能,因此必须仔细设置。

Talking about Stale Threshold, you can select its value from the drop-down list, with the default value as 1 day (24 Hours).

关于过时阈值,您可以从下拉列表中选择其值,默认值为1天(24小时)。

You can also set a Stale Threshold value that is not available in the drop-down list using T-SQL. The following example sets a Stale Threshold as 10 Hours.

您还可以使用T-SQL设置下拉列表中不可用的过时阈值。 以下示例将“过时阈值”设置为10小时。

ALTER DATABASE AdventureWorksDW2017
SET QUERY_STORE ( OPERATION_MODE = READ_WRITE,MAX_PLANS_PER_QUERY = 200,WAIT_STATS_CAPTURE_MODE = ON,QUERY_CAPTURE_MODE = CUSTOM,QUERY_CAPTURE_POLICY = (EXECUTION_COUNT = 30,STALE_CAPTURE_POLICY_THRESHOLD = 10 HOURS,TOTAL_COMPILE_CPU_TIME_MS = 1000,TOTAL_EXECUTION_CPU_TIME_MS = 100 ))

And the great part is, once the above code is executed, the value “10 Hours” is added in the drop-down list.

最重要的是,一旦执行了上述代码,就会在下拉列表中添加值“ 10 Hours”。

结论 (Conclusion )

SQL Server Query Store using SSMS 18.4 together with SQL Server 2019 is a great tool to troubleshoot query performance and we covered several options added in the GUI in this article.

结合使用SSMS 18.4和SQL Server 2019SQL Server Query Store是解决查询性能问题的好工具,我们在本文中介绍了GUI中添加的几个选项。

翻译自: https://www.sqlshack.com/sql-server-query-store-options-in-ssms-18-4/

ssms .net3.5

ssms .net3.5_SSMS 18.4中SQL Server查询存储选项相关推荐

  1. 运行中SQL Server查询存储

    介绍 (Introduction) The Query Store is a new feature in SQL Server 2016 that will greatly improve the ...

  2. SQL Server查询存储–概述

    The SQL Server Query Store is a relatively new feature introduced in SQL Server 2016. It is basicall ...

  3. C# 学习笔记(18)操作SQL Server 中

    C# 学习笔记(18)操作SQL Server 中 数据库基础操作 SQL语法可以参考 菜鸟教程 或者微软官方的SQL示例 注意SQL不区分大小写 查 1.基础查询 --最基础的查询语句, selec ...

  4. 探索SSMS中SQL Server索引属性

    This article gives you an insight into SQL Server Index properties in SSMS. 本文使您可以深入了解SSMS中SQL Serve ...

  5. sql azure 语法_Azure Data Studio中SQL Server架构比较扩展

    sql azure 语法 This article explores the SQL Server Schema Compare extension in the Azure Data Studio. ...

  6. 干货 | SSMS客户端连接京东云RDS SQL Server配置方法

    干货 | SSMS客户端连接京东云RDS SQL Server配置方法 原创: 于振江 京东云开发者社区 微软SQL Server, Oracle数据库以及MySQL系列占据了关系型数据库市场的绝对份 ...

  7. 如何在SQL Server查询语句(Select)中检索存储过程(Store Procedure)的结果集

    如何在SQL Server查询语句(Select)中检索存储过程(Store Procedure)的结果集?(2006-12-14 09:25:36) 与这个问题具有相同性质的其他描述还包括: 如 ...

  8. SQL Server查询中特殊字符的处理方法

    来源:http://database.51cto.com/art/201009/227766.htm SQL Server查询中,经常会遇到一些特殊字符,比如单引号"'"等,这些字 ...

  9. sql azure 语法_Azure Data Studio中SQL Server Profiler

    sql azure 语法 In this article, we will explore SQL Server Profiler in Azure Data Studio in detail inc ...

最新文章

  1. JS事件委托或者事件代理原理以及实现
  2. C++实现质因数分解
  3. linux putty 永久修改字体大小
  4. 记录皮尔逊相关系数-相似性比较算法
  5. Android 取得 ListView中每一个Item项目的值
  6. 版本1.8.1Go安装以及语法高亮配置
  7. 作者:曾伟,电子科技大学副教授。
  8. 倾听用户呼吁Skype决定开源
  9. 配置和使用APM功能和调用链分析功能
  10. django 发送php,django 使用 request 获取浏览器发送的参数
  11. AttributeError: module ‘tensorflow‘ has no attribute ‘ConfigProto‘
  12. 安卓+JAVA实例开发源码
  13. 球员岁月齐祖辉煌,执教生涯尤胜当年
  14. 东方影都2003_东方影都旅游攻略|电影博物馆amp;外景街最in玩法,get了吗?
  15. 单片机蓝牙烧录_实现蓝牙HC-05、06与单片机的连接及与手机通信
  16. 南京沁恒推出的国产 M3 架构芯片与意法半导体 M3 芯片对比
  17. 如何成为一名卓越的软件工程师
  18. Uniqlo与Fast Retailing发出警告 46万消费者账号遭入侵
  19. 如何用c++写联机小游戏?
  20. JAVA 中文字符转为拼音字符串

热门文章

  1. 主题:JAVA 桥接模式
  2. ajax beforeSend中无效果
  3. UIKit框架-高级控件Swift版本: 5.UITextView方法/属性详解
  4. LeetCode(728)——自除数(JavaScript)
  5. canvas实现抽奖插件—大转盘和九宫格
  6. 有没有一百万的电脑配置?
  7. 为什么人们常说“十个创业九个死”?
  8. 为什么要多读书?多看书?
  9. 为什么越普通的男人越自信?
  10. 全职宝妈做自媒体怎么样