t–sql pl–sql

SQL Server探查器 (SQL Server Profiler )

SQL Server Profiler is a monitoring tool that you can use to create and manage SQL Server traces for monitoring SQL Server instance activity. These trace files can later be analyzed and replayed. Profiler has a graphical interface, which makes it easy to use

SQL Server Profiler是一个监视工具,可用于创建和管理SQL Server跟踪以监视SQL Server实例活动。 这些跟踪文件可以在以后进行分析和重放。 Profiler具有图形界面,易于使用

Besides auditing actions that happened on a SQL Server instance, it is useful for SQL Server performance troubleshooting, as it can track stored procedure and query execution and show the slow ones, capture statements and events that caused performance degradation, replay the specific set of events in another environment for testing purposes, etc.

除了审核在SQL Server实例上发生的操作外,它对于SQL Server性能故障排除很有用,因为它可以跟踪存储过程和查询执行,并显示慢速过程,捕获导致性能下降的语句和事件,重播特定的事件集在另一个环境中进行测试等。

To start SQL Server Profiler:

要启动SQL Server Profiler:

  1. Start, All Programs (Windows + C for Windows 8) 开始”,“所有程序” (适用于Windows 8的Windows + C)
  2. SQL Server ProfilerSQL Server Profiler

Or

要么

  1. SQL Server Management StudioSQL Server Management Studio
  2. Tools menu, select 工具”菜单中,选择“ SQL Server Profiler SQL Server Profiler”

Or

要么

  1. Command Prompt命令提示符
  2. profiler分析器
  3. EnterEnter

Now, you should create traces that will collect the information you need in order to monitor and troubleshoot SQL Server performance

现在,您应该创建跟踪,该跟踪将收集所需的信息,以监视和解决SQL Server性能

To create a new trace:

要创建新的跟踪:

  1. SQL Server Profiler, open SQL Server Profiler中 ,在菜单中打开“ File in the menu文件”
  2. New Trace新跟踪
  3. Select a SQL Server instance, Authentication Mode, and provide credentials选择一个SQL Server实例,身份验证模式,并提供凭据
  4. Event selection tab, click 事件选择选项卡中,单击Show all events显示所有事件
  5. Select the events and event columns you want to trace

    选择要跟踪的事件和事件列

    To capture information about events that occur on a database, e.g. data and log files auto-grow and auto-shrink events, select these events in Database event type

    要捕获有关数据库中发生的事件的信息,例如数据和日志文件的自动增长和自动收缩事件,请在数据库事件类型中选择这些事件

    To trace various errors, such as CPU threshold exceeded, select this event in the Errors and Warnings EVENT type

    若要跟踪各种错误,例如超过了CPU阈值,请在“ 错误和警告” EVENT类型中选择此事件

  6. General tab, select whether to save the trace to a file or to a table常规”选项卡中,选择是将跟踪保存到文件还是表中
  7. Run 运行

All events that belong to the event types selected for tracing will be captured

将捕获属于选定要跟踪的事件类型的所有事件

Although SQL Server Profiler provides a lot of useful information, some DBAs avoid using it on a production server, as it can add significant overhead. Also, if you haven’t configured SQL Server trace collection property to collect just the information you really need for analysis, there will be plenty of collected data which might be difficult to analyze

尽管SQL Server Profiler提供了许多有用的信息,但是某些DBA避免在生产服务器上使用它,因为它会增加大量开销。 另外,如果您尚未配置SQL Server跟踪收集属性来仅收集您真正需要分析的信息,则将有很多收集的数据可能难以分析

Windows性能监视器 (Windows Performance Monitor)

Windows Performance Monitor is a monitoring tool shipped with Windows. It tracks various performance counters and monitors overall system and application performance. The counter values are shown in real-time graphs and can be saved in log files and used for later analysis

Windows Performance Monitor是Windows附带的监视工具。 它跟踪各种性能计数器,并监视整个系统和应用程序的性能。 计数器值显示在实时图形中,可以保存在日志文件中并用于以后的分析

Windows Performance Monitor provides a wide range of counters. Monitoring too many counters will affect system performance and make analysis difficult, so it’s necessary to determine monitoring goals first, and then select the counters to monitor. A well-selected set of counters provides enough information for useful conclusions, quick diagnosis, and finding the problem origin, therefore efficient problem solving. Capturing too little or wrong counters will not provide enough information for useful conclusions, might be misleading and induce wrong conclusions

Windows Performance Monitor提供了广泛的计数器。 监视过多的计数器会影响系统性能并使分析变得困难,因此有必要先确定监视目标,然后选择要监视的计数器。 一组经过精心选择的计数器可提供足够的信息,以得出有用的结论,快速诊断并找到问题的根源,从而有效地解决问题。 捕获的计数器太少或错误将无法为有用的结论提供足够的信息,可能会产生误导并得出错误的结论

When it comes to selecting the counters, it’s necessary to understand what they represent, what are acceptable values, whether there is a threshold, or the value determined based on a trend line

选择计数器时,必须了解它们代表什么,可接受的值,是否存在阈值或根据趋势线确定的值

To open Windows Performance Monitor:

要打开Windows性能监视器:

  • Start, Run (Windows + R for Windows 8), type 开始”,“运行” (对于Windows 8为Windows + R),键入perfmon, and press perfmon ,然后按EnterEnter键。
  • Control Panel, System and Security, Administrative Tools, and click 控制面板”,“系统和安全性”,“管理工具” ,然后单击“ Performance Monitor性能监视器”。

To add a counter:

要添加计数器:

  1. Add Counters in the context menu, or click the 添加计数器 ”,或单击菜单中的“ Add icon in the menu添加”图标
  2. Select the computer you want to monitor选择您要监视的计算机
  3. In the list of available counters, select the counter group e.g. MSSQL$2012:Buffer Manager and then Lazy writes/sec

    在可用计数器列表中,选择计数器组,例如MSSQL $ 2012:Buffer Manager ,然后选择“ Lazy writes / sec”

Windows Performance Monitor shows useful information in comprehensive real-time graphs and can save historical data for a long time, so it can be used for later analysis. Its disadvantages are that it cannot provide sufficient information for deep analysis nor show a trend line or a threshold in the graph

Windows Performance Monitor在全面的实时图形中显示有用的信息,并且可以保存很长时间的历史数据,因此可以用于以后的分析。 它的缺点是无法提供足够的信息进行深入分析,也无法在图中显示趋势线或阈值

SQL Server活动监视器 (SQL Server Activity Monitor)

SQL Server Activity Monitor is a feature available in SQL Server Management Studio, useful for quick and basic SQL Server activity monitoring. It shows only information about the SQL Server processes and their effect on SQL Server performance

SQL Server活动监视器是SQL Server Management Studio中提供的功能,可用于快速和基本SQL Server活动监视。 它仅显示有关SQL Server进程及其对SQL Server性能的影响的信息

It shows % Processor Time, Waiting Tasks, Database I/O, and Batch Requests/sec in the Overview pane; the list of currently running processes on the SQL database in the Processes pane; the information about waits for resources in the Resource Waits pane; a list of all databases on the SQL Server instance along with information about the database files, their paths, and names in the Data File I/O pane, and the list of the queries recently executed that use most of memory, disk, and network resources in the Recent Expensive Queries pane

它在“ 概述”窗格中显示“ 处理器时间百分比”,“等待任务”,“数据库I / O”和“ 批处理请求数/秒 ”; “ 进程”窗格中SQL数据库上当前正在运行的进程的列表; “ 资源等待”窗格中有关等待资源的信息; SQL Server实例上的所有数据库的列表,以及有关数据库文件,其路径和“ 数据文件I / O”窗格中的名称的信息 ,以及最近执行的使用大部分内存,磁盘和网络的查询的列表最近昂贵查询窗格中的资源

To start Activity Monitor, right-click the SQL Server instance in Object Explorer and select Activity Monitor

要启动活动监视器,请在对象资源管理器中右键单击SQL Server实例,然后选择“ 活动监视器”

Activity Monitor cannot provide data for deep investigation, store historical records for later analysis, nor can additional parameters be monitored

活动监视器无法提供用于深度调查的数据,无法存储历史记录以供以后分析,也无法监视其他参数

SQL Server数据收集器 (SQL Server Data Collector )

SQL Server Data Collector is another SQL Server Management Studio feature that can be used for SQL Server performance monitoring and troubleshooting. It’s available in SQL Server 2008 and later. Data Collector can collect performance metrics on multiple SQL Server instances and store them in a single repository. Data is collected based on the specification used. There are three built-in specifications that provide automatic collection of the most common performance metrics – disk usage, query statistics, and server activity. Custom data collector specifications can be created, but it requires coding. Data collection is possible only if SQL Server Agent is running and Management Data Warehouse is configured

SQL Server Data Collector是另一个SQL Server Management Studio功能,可用于SQL Server性能监视和故障排除。 它在SQL Server 2008和更高版本中可用。 Data Collector可以收集多个SQL Server实例上的性能指标并将它们存储在单个存储库中。 根据使用的规范收集数据。 共有三个内置规范,可自动收集最常见的性能指标-磁盘使用率,查询统计信息和服务器活动。 可以创建自定义数据收集器规范,但是需要编码。 仅当SQL Server代理正在运行并且配置了管理数据仓库时,才可以进行数据收集

To open Data Collection reports

打开数据收集报告

  1. In SQL Server Management Studio Object Explorer, expand Management
  2. 在“ SQL Server Management Studio 对象资源 管理 器”中 ,展开“ 管理”。
  3. Data Collection and select 数据收集”,然后选择Reports“报告”
  4. Select any of the available reports – Server Activity History, Query Statistics History, or Disk Usage Summary

    选择任何可用的报告- 服务器活动历史记录,查询统计信息历史记录磁盘使用情况摘要

动态管理视图(DMV) (Dynamic Management Views (DMVs))

Besides the monitoring utilities available in Windows and SQL Server Management Studio, Dynamic Management Views (DMVs) can also be used to monitor SQL Server performance and troubleshoot issues. These views are: sys.dm_exec_sessions, sys.dm_os_performance_counters, sys.dm_os_memory_brokers, sys.dm_os_memory_nodes, sys.dm_exec_procedure_stats, sys._dm_os_sys_info, sys.dm_exec_requests, sys.dm_exec_requests, and many more

除了Windows和SQL Server Management Studio中可用的监视实用程序之外,动态管理视图(DMV)也可以用于监视SQL Server性能并解决问题。 这些视图是:sys.dm_exec_sessions,sys.dm_os_performance_counters,sys.dm_os_memory_brokers,sys.dm_os_memory_nodes,sys.dm_exec_procedure_stats,sys._dm_os_sys_info,sys.dm_exec_request

We’ll present only a few commonly used views for SQL Server performance monitoring in this article

在本文中,我们将仅提供一些用于SQL Server性能监视的常用视图

sys.dm_exec_sessions – returns a row for every session on the queried SQL Server instance, along with details such as the name of the program that initiated the session, session status, SQL Server login, various time counters, and more

sys.dm_exec_sessions –为查询SQL Server实例上的每个会话返回一行,以及诸如启动该会话的程序的名称,会话状态,SQL Server登录,各种时间计数器等详细信息

sys.dm_exec_requests – returns a row for every user and system request being executed on the SQL Server instance. To find the blocked requests, search for the requests where the status column value is ‘suspended’

sys.dm_exec_requests –为在SQL Server实例上执行的每个用户和系统请求返回一行。 要查找被阻止的请求,请搜索状态列值为“已暂停”的请求

sys.dm_exec_query_stats – returns a row for every query statement in a cached query plan. It provides information about average, minimal, maximal, and total processor time used by the plan, along with other useful information for performance analysis

sys.dm_exec_query_stats –为高速缓存的查询计划中的每个查询语句返回一行。 它提供有关计划使用的平均,最小,最大和总处理器时间的信息,以及用于性能分析的其他有用信息。

sys.dm_os_performance_counters – returns a row for each SQL Server performance counter. It provides a quick way to find out current performance counter values. However, there are five counter types, and to be sure you’re interpreting the returned values correctly, you have to know how to calculate a value for each counter type. It’s easiest with the counter type 65792, as no calculation is needed. Counter types 1073874176, 537003264, and 272696576 require additional calculation in order to provide the metric current value

sys.dm_os_performance_counters –为每个SQL Server性能计数器返回一行。 它提供了一种快速的方法来找出当前的性能计数器值。 但是,有五种计数器类型,为确保正确解释返回的值,必须知道如何为每种计数器类型计算一个值。 对于计数器类型65792,这是最简单的,因为不需要计算。 计数器类型1073874176、537003264和272696576需要进行额外的计算才能提供公制电流值

If the values are not properly calculated, they can be confusing, misleading, and lead to wrong conclusions

如果这些值的计算不正确,可能会造成混淆,误导并导致错误的结论

SQL Server扩展事件 (SQL Server Extended Events )

SQL Server Extended Events allow collecting information useful for troubleshooting SQL Server performance issues. They enable finding the most expensive queries, latch, deadlock, and blocking causes, troubleshooting excessive processor usage, and more

SQL Server扩展事件允许收集有助于解决SQL Server性能问题的信息。 它们使您能够查找最昂贵的查询,闩锁,死锁和阻塞原因,对过多的处理器使用情况进行故障排除等

To use Extended Events for performance monitoring, determine which events you want to monitor, and create a session using SQL Server Management Studio options, or T-SQL

若要将扩展事件用于性能监视,请确定要监视的事件,并使用SQL Server Management Studio选项或T-SQL创建会话。

To create the ReadWriteActivity session to capture event data for completed file reads and writes, and write it from the log cache file to the physical log file:

要创建ReadWriteActivity会话以捕获事件数据以完成文件读写,并将其从日志缓存文件写入物理日志文件:


CREATE EVENT SESSION ReadWriteActivity
ON SERVERADD EVENT sqlserver.file_read_completed,
ADD EVENT sqlserver.file_write_completed
ADD TARGET package0.asynchronous_file_target (SET filename = 'c:\PerfLogs\ExtELog.xel', metadatafile = 'c:\PerfLogs\ExtELog.xem')

After the session is created, to start it:

创建会话后,要启动它:

  1. Expand Management in Object Explorer
  2. 在对象资源管理器中展开管理
  3. Extended Events扩展事件
  4. Sessions扩大会议
  5. Start开始

To see the live event data with its details, select Watch Live Data from the event context menu in Object Explorer

要查看实时事件数据及其详细信息,请从对象资源管理器的事件上下文菜单中选择“ 观看实时数据

There is also the built-in system_health session started automatically at SQL Server service start up, which provides useful information for performance troubleshooting

在SQL Server服务启动时,还会自动启动内置的system_health会话,该会话为性能故障排除提供了有用的信息。

In this article, we presented the SQL Server performance monitoring utilities available in Windows and SQL Server. The information they provide and knowledge required to use them varies. Some of them, like Activity Monitor, are easy to use and require no coding, but at the same time provide only basic information useful just to get the general picture. On the other hand, Extended Events can monitor and handle various run-time errors, resource bottlenecks, blocking, etc. But to get the most of them, coding is required

在本文中,我们介绍了Windows和SQL Server中可用SQL Server性能监视实用程序。 他们提供的信息和使用它们所需的知识各不相同。 其中一些工具(例如“活动监视器”)易于使用且不需要编码,但同时仅提供仅用于获取一般图片的基本信息。 另一方面,扩展事件可以监视和处理各种运行时错误,资源瓶颈,阻塞等。但是要充分利用它们,需要进行编码

目录 (Table of contents)

A DBA guide to SQL Server performance troubleshooting – Part 1 – Problems and performance metrics
A DBA guide to SQL Server performance troubleshooting – Part 2 – Monitoring utilities
SQL Server性能疑难解答的DBA指南–第1部分–问题和性能指标
SQL Server性能疑难解答的DBA指南–第2部分–监视实用程序

翻译自: https://www.sqlshack.com/dba-guide-sql-server-performance-troubleshooting-part-2-monitoring-utilities/

t–sql pl–sql

t–sql pl–sql_SQL Server性能疑难解答的DBA指南–第2部分–监视实用程序相关推荐

  1. t–sql pl–sql_SQL Server性能疑难解答的DBA指南–第1部分–问题和性能指标

    t–sql pl–sql It doesn't mean that every SQL Server slowdown is a performance problem. Some specific ...

  2. t–sql pl–sql_SQL Server处理器性能指标–第3部分–指示硬件组件问题的指标

    t–sql pl–sql Part 1 and 第1部分和Part 2 of the SQL Server processor performance metrics series, we descr ...

  3. t–sql pl–sql_SQL Server处理器性能指标–第4部分–处理器指标有助于更深入的调查和故障排除

    t–sql pl–sql In the previous part of this series, we presented the processor metrics that indicate h ...

  4. t–sql pl–sql_SQL Server –在T-SQL中使用最低的度量单位

    t–sql pl–sql A client recently discovered a discrepancy on one of our reports that showed an improve ...

  5. t–sql pl–sql_SQL Server处理器性能指标–第1部分–最重要的CPU指标

    t–sql pl–sql Starting with this article, we will present the most important CPU metrics, describe th ...

  6. dbcc dbreindex server sql_SQL Server性能的提高,可通过DBCC DBREINDEX重建索引

    以下的文章主要介绍的是DBCC DBREINDEX重建索引对SQL Server性能进行提高的实际操作步骤,大多数SQL Server数据库表需要索引来对数据的实际访问速度进行提高,如果没有索引,SQ ...

  7. t–sql pl–sql_SQL View –完整的介绍和演练

    t–sql pl–sql In relational databases, data is structured using various database objects like tables, ...

  8. t–sql pl–sql_SQL串联正确完成–第1部分–可疑做法

    t–sql pl–sql This article is a part of three articles series to explore SQL Concatenation techniques ...

  9. t–sql pl–sql_SQL日期时间–您应该知道的15个重要功能!

    t–sql pl–sql Hey, folks! Hope you all are doing well. Today, in this article, we will be highlightin ...

最新文章

  1. mysql之索引组织表
  2. oracle mysql 适配器_Oracle协议适配器错误解决办法
  3. Android 利用addView 动态给Activity添加View组件
  4. 销售单据条件价格明细表
  5. 【Laro】- About Game Engine
  6. java RSA 加签验签【转】
  7. 点云的无序性_基于深度学习的激光雷达点云物体识别方法总结
  8. 一个段子教你如何认识大数据
  9. 蜡笔小新模拟器汉化版_FC蜡笔小新条码版下载-蜡笔小新条码版FC模拟器下载-电玩咖...
  10. Android emoji表情处理
  11. 【干货】火山视频去水印下载使用介绍
  12. c语言5名同学3门课程成绩,输入5名同学3门课程的成绩 求: 1)每门课程的平均成绩。2)找出最高分数所对应的学生和课程。...
  13. jeecms常见用法
  14. 浏览器事件:为什么会有捕获过程和冒泡过程?
  15. electron 双击放大事件
  16. 一名软件测试工程师的一天24小时(每天在忙什么)
  17. linux网络延迟命令,2. Linux使用ping命令查看网络延迟
  18. vue v-for遍历动态展示元素数量
  19. python数据分析 - T检验与F检验:二组数据那个更好?(一)
  20. win11禁用内置的administrator本地帐户

热门文章

  1. URAL1018 Binary Apple Tree
  2. 网页常用分享代码大全——整理摘抄至他人嘿嘿
  3. css3导航渐变 滑过显示动画
  4. 查找路径php.ini文件到底在哪里?
  5. c# winform WebBrower 控件中右键获取控件坐标
  6. rollup配置及使用
  7. LeetCode(575)——分糖果(JavaScript)
  8. LeetCode(929)——独特的电子邮件地址(JavaScript)
  9. java代码实现画板_求好心人帮找或做个JAVA画板程序 代码,主要能实现简单的画板功能!...
  10. 理财最低持有天数是什么意思?