sql azure 语法_Azure Data Studio中SQL Server Profiler

本文详细介绍了如何在Azure Data Studio中使用SQL Server Profiler,包括安装、配置和利用不同视图来监控SQL Server性能,以及如何查看执行计划。

sql azure 语法

In this article, we will explore SQL Server Profiler in Azure Data Studio in detail including download and installation, execution plans, coding T-SQL and more.

在本文中,我们将详细介绍Azure Data Studio中SQL Server Profiler,包括下载和安装,执行计划,编码T-SQL等。

Microsoft launched the cross-platform tool, which can be installed on the Windows, Linux and the MacOS. Previously its public preview launched on 15th November 2017 as SQL Operations Studio. Recently in Ignite 2018 event, Microsoft launched its general availability version on 24th September 2018 as Azure Data Studio. We can manage both the on-premises as well as the cloud database using this tool.

微软推出了跨平台工具,该工具可以安装在Windows,Linux和MacOS上。 之前,其公开预览版于2017年11月15日作为SQL Operations Studio启动。 最近在Ignite 2018活动中,Microsoft在2018年9月24日启动了其通用版本,即Azure Data Studio。 使用此工具,我们可以管理本地和云数据库。

We are getting the monthly release of the Azure Data Studio. In this article, I am using the November release of Azure Data Studio on Windows OS. The latest version of Azure Data Studio is 1.2.4.

我们将获得Azure Data Studio的每月版本。 在本文中,我正在使用Windows OS上的Azure Data Studio的十一月发行版。 最新版本的Azure Data Studio是1.2.4。

Get details of the installed Azure Data Studio from ‘ Help->about.’

从“帮助->关于”获取已安装的Azure Data Studio的详细信息。

You can download Azure Data Studio using the Microsoft docs. Download the tool as per the platform you have and install it accordingly.

您可以使用Microsoft文档下载Azure Data Studio。 根据您所拥有的平台下载该工具,然后进行相应安装。

Azure Data Studio allows adding functionality into this tool with extensions. We have many extensions available in the marketplace to download and install without any cost. Few important extensions in Azure Data Studio are as below:

Azure Data Studio允许通过扩展将此功能添加到此工具中。 我们在市场上有许多扩展程序可以免费下载和安装。 Azure Data Studio中的几个重要扩展如下:

  • SQL Server 2019 (preview): this extension provides support for the SQL Server 2019 features and enhancements including big data clusters, enhanced PolyBase, Azure notebook etc SQL Server 2019(预览版):此扩展提供对SQL Server 2019功能和增强功能的支持,包括大数据群集,增强的PolyBase,Azure笔记本等
  • SQL Server Agent: We can manage SQL Server jobs using this extension SQL Server代理:我们可以使用此扩展名管理SQL Server作业
  • Whoisactive: We can monitor and troubleshoot performance issue with this extension that runs a sp_whoIsActive stored procedure Whoisactive:我们可以使用运行sp_whoIsActive存储过程的此扩展监视和解决性能问题
  • Server Reports: We can view the server reports such as DB space usage, DB buffer usage, CPU utilization, backup growth trend using this extension 服务器报告:使用此扩展程序,我们可以查看服务器报告,例如数据库空间使用率,数据库缓冲区使用率,CPU使用率,备份增长趋势
  • Redgate SQL Search: we can search objects across multiple databases using this extension. Redgate SQL Search:使用此扩展,我们可以跨多个数据库搜索对象。
  • SQL Server Profiler: We can monitor SQL Server using this extension SQL Server Profiler:我们可以使用此扩展监视SQL Server

SQL Server探查器 (SQL Server Profiler)

SQL Server Profiler extension gives us feasibility to monitor or trace SQL Server. We can use this tool to identify problematic queries, slow running queries, monitor SQL Server performance, capture data using performance counter etc.

SQL Server Profiler扩展使我们可以监视或跟踪SQL Server。 我们可以使用此工具来识别有问题的查询,运行缓慢的查询,监视SQL Server性能,使用性能计数器捕获数据等。

First, we need to install it from the SQL Server Profiler. In the marketplace from the left menu bar, search the extension ‘SQL Server Profiler’ and Install it.

首先,我们需要从SQL Server Profiler安装它。 在市场左侧菜单栏中,搜索扩展名“ SQL Server Profiler”并安装。

It quickly installs the extension. Click on ‘Reload’ to restart the Azure Data Studio. This will activate the SQL Server Profiler extension.

它会快速安装扩展程序。 单击“重新加载”以重新启动Azure Data Studio。 这将激活SQL Server Profiler扩展。

>

>

After we restart Azure Data Studio, SQL Server Profiler extension status changes to ‘Disable or uninstall’. You can also note here that SQL Server Profiler extension is in a preview state, we might get further enhancements in coming releases.

重新启动Azure Data Studio之后,SQL Server Profiler扩展状态更改为“禁用或卸载”。 您还可以在此处注意到SQL Server Profiler扩展处于预览状态,我们可能会在后续版本中获得进一步的增强。

We can launch the SQL Server Profiler from the command pallet. Click on the View->Command Pallet -> Profiler->New Profiler

我们可以从命令托盘启动SQL Server Profiler。 单击查看->命令面板->探查器->新探查器

Alternatively, we can use the shortcut key Alt + P. It launches’ the create new profiler section’ as shown below.

或者,我们可以使用快捷键Alt +P。它将启动“创建新的探查器部分”,如下所示。

In this, we can define the session template from the drop-down list.

在此,我们可以从下拉列表中定义会话模板。

  • Standard_OnPrem: We can Monitor the SQL Server on Premise instance

    Standard_OnPrem:我们可以在前提实例上监视SQL Server
  • Standard_Azure: We can monitor Azure SQL DB using this template

    Standard_Azure:我们可以使用此模板监视Azure SQL DB
  • TSQL_OnPrem: We can monitor the transact SQL statements using this template

    TSQL_OnPrem:我们可以使用此模板监视事务SQL语句

Select the session template and specifies a session name. Click on Create to start the session.

选择会话模板并指定会话名称。 单击创建以开始会话。

This starts the profiler session as shown here.

如此处所示,这将启动事件探查器会话。

On top of the profiler window, we get the following menu bar.

在事件探查器窗口的顶部,我们得到以下菜单栏。

  • Start: If the profiler session is already running, it is disabled

    开始:如果事件探查器会话已在运行,则将其禁用
  • Stop: Click on ‘stop’ to stop capturing the details

    停止:单击“停止”以停止捕获详细信息
  • Pause Capture: We can pause the trace session using this option. While the session is pause state, it will not capture the event until it is resumed

    暂停捕获:我们可以使用此选项暂停跟踪会话。 当会话处于暂停状态时,它将不会捕获事件,直到恢复为止
  • Auto Scroll – On: it automatically scrolls down the captured events with this option. If we do not want to scroll automatically, click on it and it changes to Auto Scroll – off

    自动滚动–开启:使用此选项自动向下滚动捕获的事件。 如果我们不想自动滚动,请单击它,然后将其更改为“自动滚动”。
    • Standard View

      标准检视
    • TSQL View

      TSQL视图
    • Tuning View

      调整视图
    • TSQL_Locks View

      TSQL_Locks视图
    • TSQL_Duration View

      TSQL_Duration视图

Let us view each view in below images.

让我们在下图中查看每个视图。

Standard View: In the standard view, we get complete information about the query such as CPU, Reads, Writes, Duration, Login, Text data etc.

标准视图:在标准视图中,我们获得有关查询的完整信息,例如CPU,读取,写入,持续时间,登录名,文本数据等。

In other views, we can get specific information filtered out from the standard view.

在其他视图中,我们可以从标准视图中滤除特定信息。

TSQL View: In this view, we get the details about running SQL queries.

TSQL视图:在此视图中,我们获得有关运行SQL查询的详细信息。

Tuning View: In tuning view, we get information about the duration of SQL batch and additional details such as object type, login name.

调整视图:在调整视图中,我们获得有关SQL批处理持续时间的信息以及其他详细信息,例如对象类型,登录名。

Click on the ‘Details’ to get additional information.

单击“详细信息”以获取其他信息。

TSQL_Locks Views: In this view, we can see the reads, write, duration, application name, CPU for the running t-SQL.

TSQL_Locks视图:在此视图中,我们可以查看正在运行的t-SQL的读取,写入,持续时间,应用程序名称,CPU。

TSQL_Duration View: We can view the duration information for the t-SQL.

TSQL_Duration视图:我们可以查看t-SQL的持续时间信息。

查看Azure Data Studio中的执行计划 (View the execution plan in Azure Data Studio)

We can view the execution plan as well for the queries captured in the SQL Server Profiler. In the profiler window, click on the split editor. The arrow in the screenshot highlights this icon.

我们也可以查看SQL Server Profiler中捕获的查询的执行计划。 在事件探查器窗口中,单击拆分编辑器。 屏幕截图中的箭头突出显示了此图标。

It opens up an editor window on the right side.

它会在右侧打开一个编辑器窗口。

Now, suppose we want to see the execution plan of the query captured using the profiler event.

现在,假设我们要查看使用事件探查器事件捕获的查询的执行计划。

SELECT TOP (1000) [CustomerID]
      ,[CustomerName]
      ,[CustomerCategoryName]
      ,[PrimaryContact]
      ,[AlternateContact]
      ,[PhoneNumber]
      ,[FaxNumber]
      ,[BuyingGroupName]
      ,[WebsiteURL]
      ,[DeliveryMethod]
      ,[CityName]
      ,[DeliveryLocation]
      ,[DeliveryRun]
      ,[RunPosition]
  FROM [WideWorldImporters].[Website].[Customers]
  order by customername

In the right split window, right click and then click on ‘New File’.

在右拆分窗口中,右键单击,然后单击“新文件”。

This opens us the query editor window in the split window.

这将在拆分窗口中打开查询编辑器窗口。

Now, Copy the query from the left window and paste into the right split window.

现在,从左侧窗口复制查询,然后粘贴到右侧拆分窗口中。

Click on the ‘Explain’ in the right window and you can see the execution plan from the ‘Query Plan’ option.

单击右侧窗口中的“解释”,您可以从“查询计划”选项中查看执行计划。

We can view the XML execution plan as well. Click on the ‘Results’ near to the ‘Query Plan’. You get the XML Showplan using this option.

我们也可以查看XML执行计划。 单击“查询计划”附近的“结果”。 您可以使用此选项获得XML Showplan。

Now, Click on the XML Showplan and you can view the detailed XML execution plan in the new window as shown here.

现在,单击XML Showplan,您可以在新窗口中查看详细的XML执行计划,如下所示。

As shown above, you can view the execution plan in both the graphical as well as in XML plan. Look out the operators in the execution plan and troubleshoot the issue.

如上所示,您可以在图形计划和XML计划中查看执行计划。 在执行计划中查找操作员并解决问题。

结论 (Conclusion)

SQL Server Profiler is a useful enhancement to Azure Data Studio. However, currently, in a preview state, we cannot define the custom template or events to capture the relevant data. We learned to use the SQL Server Profiler in this article. This extension might get further enhancements in an upcoming release.

SQL Server Profiler是对Azure Data Studio的有用增强。 但是,当前,在预览状态下,我们无法定义自定义模板或事件来捕获相关数据。 我们在本文中学习了使用SQL Server Profiler。 此扩展可能会在即将发布的版本中得到进一步的增强。

翻译自: https://www.sqlshack.com/sql-server-profiler-in-azure-data-studio/

sql azure 语法

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值