search
HomeDatabaseMysql Tutorial使用sp_monitor 查看SQL Server统计信息

SQL Server提供了sp_monitor存储过程可以方便我们查看SQL Server性能统计信息,包括CPU/Network/IO,通过这些信息可以对自己的数

SQL Server提供了sp_monitor存储过程可以方便我们查看SQL Server性能统计信息,包括CPU/Network/IO,通过这些信息可以对自己的数据库性能状况有一个大致的了解。

下面的示例报告有关 SQL Server 繁忙程度的信息:

 

 

每个列名的解释:

 

列名说明

last_run

上次运行 sp_monitor 的时间。

current_run

本次运行 sp_monitor 的时间。

sp_monitor 自运行以来所经过的秒数。

cpu_busy

服务器计算机的 CPU 处理 SQL Server 工作所用的秒数。

io_busy

SQL Server 在输入和输出操作上花费的秒数。

空闲

SQL Server 已空闲的秒数。

packets_received

SQL Server 读取的输入数据包数。

packets_sent

SQL Server 已写入的输出数据包数。

packet_errors

SQL Server 在读取和写入数据包时遇到的错误数。

total_read

SQL Server 读取的次数。

total_write

SQL Server 写入的次数。

total_errors

SQL Server 在读取和写入时遇到的错误数。

connections

登录或尝试登录 SQL Server 的次数。

对于每一列,统计信息将以 number(number)-number% 或 number(number) 的格式输出。第一个number 是指重新启动 SQL Server 以来的秒数(对于cpu_busy、io_busy 和idle)或总数目(对于其他变量)。圆括号中的number 是指上次运行 sp_monitor 以来的秒数或总数目。百分比是自上次运行sp_monitor 以来的时间百分比。例如,如果报告中cpu_busy 显示为 4250(215)-68%,,则自 SQL Server 上次启动以来,CPU 工作了 4250 秒;自上次运行sp_monitor 以来,CPU 工作了 215 秒;自上次运行sp_monitor 以来占总时间的 68%。

如果需要保存数据的话可以使用下面的系统统计函数:

Table 1 System Statistical Functions

 

Function Description

@@CONNECTIONS The number of connections or attempted connections.

@@CPU_BUSY Timer ticks that the CPU has been working for SQL Server.

@@IDLE Time in timer ticks that SQL Server has been idle.

@@IO_BUSY Timer ticks that SQL Server has spent performing I/O operations.

@@PACKET_ERRORS Number of network packet errors that have occurred.

@@PACK_RECEIVED Number of packets read from the network.

@@PACK_SENT Number of packets written to the network.

@@TIMETICKS Number of millionths of a second in a timer tick.

@@TOTAL_ERRORS Number of read/write errors during I/O operations.

@@TOTAL_READ Number of disk reads.

@@TOTAL_WRITE Number of disk writes.

linux

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
MySQL: BLOB and other no-sql storage, what are the differences?MySQL: BLOB and other no-sql storage, what are the differences?May 13, 2025 am 12:14 AM

MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

MySQL Add User: Syntax, Options, and Security Best PracticesMySQL Add User: Syntax, Options, and Security Best PracticesMay 13, 2025 am 12:12 AM

ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

MySQL: How to avoid String Data Types common mistakes?MySQL: How to avoid String Data Types common mistakes?May 13, 2025 am 12:09 AM

ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters

MySQL: String Data Types and ENUMs?MySQL: String Data Types and ENUMs?May 13, 2025 am 12:05 AM

MySQloffersechar, Varchar, text, Anddenumforstringdata.usecharforfixed-Lengthstrings, VarcharerForvariable-Length, text forlarger text, AndenumforenforcingdataAntegritywithaetofvalues.

MySQL BLOB: how to optimize BLOBs requestsMySQL BLOB: how to optimize BLOBs requestsMay 13, 2025 am 12:03 AM

Optimizing MySQLBLOB requests can be done through the following strategies: 1. Reduce the frequency of BLOB query, use independent requests or delay loading; 2. Select the appropriate BLOB type (such as TINYBLOB); 3. Separate the BLOB data into separate tables; 4. Compress the BLOB data at the application layer; 5. Index the BLOB metadata. These methods can effectively improve performance by combining monitoring, caching and data sharding in actual applications.

Adding Users to MySQL: The Complete TutorialAdding Users to MySQL: The Complete TutorialMay 12, 2025 am 12:14 AM

Mastering the method of adding MySQL users is crucial for database administrators and developers because it ensures the security and access control of the database. 1) Create a new user using the CREATEUSER command, 2) Assign permissions through the GRANT command, 3) Use FLUSHPRIVILEGES to ensure permissions take effect, 4) Regularly audit and clean user accounts to maintain performance and security.

Mastering MySQL String Data Types: VARCHAR vs. TEXT vs. CHARMastering MySQL String Data Types: VARCHAR vs. TEXT vs. CHARMay 12, 2025 am 12:12 AM

ChooseCHARforfixed-lengthdata,VARCHARforvariable-lengthdata,andTEXTforlargetextfields.1)CHARisefficientforconsistent-lengthdatalikecodes.2)VARCHARsuitsvariable-lengthdatalikenames,balancingflexibilityandperformance.3)TEXTisidealforlargetextslikeartic

MySQL: String Data Types and Indexing: Best PracticesMySQL: String Data Types and Indexing: Best PracticesMay 12, 2025 am 12:11 AM

Best practices for handling string data types and indexes in MySQL include: 1) Selecting the appropriate string type, such as CHAR for fixed length, VARCHAR for variable length, and TEXT for large text; 2) Be cautious in indexing, avoid over-indexing, and create indexes for common queries; 3) Use prefix indexes and full-text indexes to optimize long string searches; 4) Regularly monitor and optimize indexes to keep indexes small and efficient. Through these methods, we can balance read and write performance and improve database efficiency.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.