sql server 性能
“The goal of monitoring databases is to assess how a server is performing. Effective monitoring involves taking periodic snapshots of current performance to isolate processes that are causing problems, and gathering data continuously over time to track performance trends“ [1]
“监视数据库的目的是评估服务器的性能。 有效的监视包括对当前性能进行定期快照以隔离引起问题的流程,并随着时间的推移不断收集数据以跟踪性能趋势” [1]
Monitoring shows what is going on with SQL Server and provides the information necessary to best tune. It enables DBAs to be proactive, find, and fix the problems before they affect their systems. Regular database performance monitoring and fixing diagnosed issues provides shorter system response time, better through put and overall performance. The performance parameters that will be considered as optimal depend on many software and hardware factors, but also on your environment and application requirements -if slow running queries are acceptable in manufacturing industry, they are not in banks. This means you have to determine your monitoring goals first
监视显示SQL Server的运行状况,并提供最佳调整所需的信息。 它使DBA能够在问题影响系统之前主动,发现并修复问题。 定期的数据库性能监视和修复已诊断的问题可以缩短系统响应时间,并提高放置和总体性能。 被认为是最佳的性能参数取决于许多软件和硬件因素,还取决于您的环境和应用程序要求-如果制造业中可接受缓慢运行的查询,则不在银行中。 这意味着您必须首先确定监视目标
SQL Server监视目标 (SQL Server monitoring goals)
One of the challenges with monitoring is to determine what should be monitored and what your monitoring goals are. This depends on many factors, and can change over time. The reasons for SQL Server monitoring can be different. If you want to use monitoring to ensure your system is safe from intruders, monitor user activity and failed logins
监视的挑战之一是确定应监视的内容以及监视的目标。 这取决于许多因素,并且会随着时间而变化。 SQL Server监视的原因可能有所不同。 如果要使用监视来确保您的系统不受入侵者的影响,请监视用户活动和失败的登录
In this article, we will focus on the performance monitoring goals – determining optimal performance for your server, performance trends, and whether the existing hardware is sufficient; finding performance problems and what causes them, seeing how different applications/loads affect performance, various tests, etc.
在本文中,我们将重点关注性能监视目标–确定服务器的最佳性能,性能趋势以及现有硬件是否足够; 查找性能问题及其原因,查看不同的应用程序/负载如何影响性能,进行各种测试等。
监视哪些组件 (What components to monitor)
Depending on your goals, different components should be monitored. As excessive monitoring adds overhead to performance, it’s recommended to be selective when choosing components to monitor
根据您的目标,应该监视不同的组件。 由于过多的监视会增加性能开销,因此建议在选择要监视的组件时选择选择性
The SQL Server performance is affected by the operating system, database and client applications, hardware configuration, and network. Therefore, the most important components for performance monitoring are memory and CPU usage, disk activity, and network traffic. Each of these areas has multiple metrics that can be audited, e.g. average disk sec/read, average disk sec/write, disk queue length, etc. For most of the metrics the values shown can be average, total, and current
SQL Server的性能受操作系统,数据库和客户端应用程序,硬件配置和网络的影响。 因此,用于性能监视的最重要的组件是内存和CPU使用率,磁盘活动以及网络流量。 这些区域中的每个区域都有多个可以审核的指标,例如,平均磁盘秒数/读取,平均磁盘秒数/写入,磁盘队列长度等。对于大多数指标,显示的值可以是平均值,总计和当前值。
Another question is how often to collect performance counter data. This also depends on the monitoring goals. The time range spans from real-time monitoring where data is collected every second, to every 5, 15, or 30 seconds. Again, keep in mind that shorter time range brings overhead
另一个问题是收集性能计数器数据的频率。 这也取决于监视目标。 时间范围从实时监视(每秒钟收集一次数据)到每5、15或30秒一次。 同样,请记住,较短的时间范围会带来开销
There are two approaches for monitoring –seeing the monitored data real time in chart mode on the screen only, and also saving it into files to able to analyze them afterwards. The later enables creating a performance baseline
监视的方法有两种-仅在屏幕上以图表方式实时查看监视的数据,还可以将其保存到文件中以便以后进行分析。 稍后可以创建性能基准
SQL Server监控信息分析 (Analysis of SQL Server monitored information)
Analysis of the monitored information should answer what is occurring and why. It shows what components need attention; indicate problems, bottlenecks, locks, and other issues
对所监视信息的分析应回答正在发生的事情以及原因。 它显示了哪些组件需要注意; 指出问题,瓶颈,锁和其他问题
“This information lets you make changes that can improve performance, such as adding more memory, changing indexes, correcting coding problems with Transact-SQL statements or stored procedures, and so on, depending on the type of analysis performed” [2]
“此信息使您可以进行更改,以提高性能,例如添加更多的内存,更改索引,更正Transact-SQL语句或存储过程的编码问题等,具体取决于执行的分析类型” [2]
If the monitored information doesn’t clearly indicate the cause of the problem, monitoring additional components and metrics can help. If the analysis shows that you’re monitoring more events than you need, remove the unnecessary ones, or apply filters to record the event only if it exceeds the specified limit
如果所监视的信息不能清楚地表明问题的原因,则监视其他组件和指标可以有所帮助。 如果分析显示您正在监视的事件超出了需要,请删除不必要的事件,或者仅在事件超出指定限制时应用过滤器来记录事件
设定基准 (Set a baseline)
A baseline is a set of values that determine optimal performance of your system. Once the baseline is defined, you can compare the current performance metrics to it, determine how far from optimal your system performance is, and what the best course of action is. The values for the baseline can be obtained only when no problems occur
基线是确定系统最佳性能的一组值。 定义基准后,您可以将其与当前性能指标进行比较,确定与最佳系统性能之间的差距以及最佳的解决方案。 仅当没有问题发生时才能获得基线值
All metrics that are significantly lower or higher than the baseline values should be investigated. For example, if the disk read and write are much lower than the baseline value, consider index optimization
应该调查所有明显低于或高于基线值的指标。 例如,如果磁盘的读写次数远低于基准值,请考虑进行索引优化
Once the baseline is set and the metrics for tracking are determined, save the monitoring configuration. Keep in mind that significant changes in your environment – hardware, or software, might need new analysis of monitored events and a new baseline created
设置基线并确定跟踪指标后,请保存监视配置。 请记住,您的环境(硬件或软件)中的重大更改可能需要对受监视事件进行新分析并创建新基准
重播监视的事件 (Replay monitored events)
When monitored events are saved into a file, you can use them on a copy of your production database to replay all events or one by one, at the same or different speed, analyze the performance, and do the necessary adjustments. The replay events feature is not available in all monitoring tools. The feature is available in SQL Server Profiler, which is supported in Enterprise, Business Intelligence, and Standard SQL Server editions
将受监视的事件保存到文件中后,可以在生产数据库的副本上使用它们,以相同或不同的速度重放所有事件或一个接一个地重放事件,分析性能并进行必要的调整。 重播事件功能并非在所有监视工具中都可用。 该功能在SQL Server Profiler中可用,在Enterprise,Business Intelligence和Standard SQL Server版本中受支持。
使用什么监控工具 (What monitoring tool to use)
This depends on the monitoring goals and type of analysis you want to perform
这取决于监视目标和要执行的分析类型
Whatever tool you choose, don’t run more than one monitoring tool on your server at the same time, as it will add overhead and make monitoring results inaccurate
无论选择哪种工具,都不要在服务器上同时运行多个监视工具,因为这会增加开销并导致监视结果不准确。
We’ve shown what performance monitoring is, why it is important and what information it should provide. It’s up to a DBA to analyze the provided information and take adequate steps manually
我们已经展示了什么是性能监控,为什么它很重要以及应该提供什么信息。 由DBA负责分析所提供的信息并手动采取适当的步骤
翻译自: https://www.sqlshack.com/sql-server-performance-basics/
sql server 性能