search
HomeDatabaseMysql Tutorial第四章SQLServer2008

第四章SQLServer2008

Jun 07, 2016 pm 03:18 PM
at lastChapter Fourseries

本文为本系列最后一章,监控内存使用。监控服务器的内存是非常重要的事情,有很多情况会引起内存消耗。所以要经常性地做检查。 本文将使用可靠性和性能监视器来获取内存相关的统计。 准备工作: 在开始之前,先来了解一下将要用到的计数器: ? Memory: Avail

本文为本系列最后一章,监控内存使用。监控服务器的内存是非常重要的事情,有很多情况会引起内存消耗。所以要经常性地做检查。

本文将使用可靠性和性能监视器来获取内存相关的统计。

 

准备工作:

在开始之前,先来了解一下将要用到的计数器:

?  Memory: Available Mbytes:提供系统上可用内存的数量。

?  Memory: Pages/sec:显示有多少页被用于读或写入硬盘,这些基于硬页面错误。

?  Paging File:%Usage:显示挂起的总数的百分比。

?  SQL Server: Buffer Manager: Buffer cache hit ratio:返回SQLServer从缓存但不是从硬盘返回的数据的百分比。

?  SQL Server: Buffer Manager: Page life expectancy:显示数据驻留在内存的平均秒数

?  SQL Server: Buffer Manager: Memory Grants Pending:等待内存工作区授予的进程数

 

步骤:

1、  打开可靠性和性能监视器,在【运行】中输入perfmon.exe

2、  选择性能监视器。

3、  去除所有已存在的计数器。

4、  添加新计数器。

5、  选择所要监视的服务器。

6、  选择下面的计数器:

 Memory: Available Mbytes
 Memory: Pages/sec
 Paging File:%Usage
 SQL Server: Buffer Manager: Buffer cache hit
 SQL Server: Buffer Manager: Page life expectancy
 SQL Server: Memory Manager: Memory Grants Pending

7、  然后点击确定。

上面这些步骤已经在前一章说明了。这里就不累赘了。

 

分析:

       在本文中,再次使用了可靠性和性能监视器这个工具。为了获取内存相关的性能计数器,需要在图形化界面中观察这些计数器。

    首先先检查Memory: Available Mbytes,这个值意味着系统的可用内存。如果发现这个值经常很低,可能表示服务器内存不足,在生产数据库中,这个值可以使用GB为单位。

    然后检查Memory: Pages/sec ,以为这因为硬页面错误导致的从磁盘读或写页面。这个值如果长期高于20,意味着内存不足使得应用程序使用虚拟内存,从而导致挂起。

    接着是Memory: pages/sec ,同时也要检查Paging File:%Usage去预估内存挂起。如果这个值经常超过20%,可能意味着内存不足。

    SQL Server: Buffer Manager: Buffer cache hit ratio:意味着数据从缓存中读取的次数,比较合理的值为大于90%。如果该值很低,可能内存不足或者需要检查索引和查询。如果你需要获得大量数据,这一步可能就会占用大量内存然后引起SQLServer从磁盘读数据而不是从内存。检查索引,确保在大表中能尽可能笔描扫描。并尽可能限制查询返回的结果行。

    检查SQL Server: Buffer Manager: Page life expectancy,表示数据页驻留在内存的秒数。微软建议最少300秒。如果在一个实例中经常低于300秒,意味着数据保留的时间少于5分钟就被移出内存。

    如果SQL Server: Memory Manager: Memory Grants Pending经常建议等待进程,你可能需要增加服务器的内存了。

    不管什么原因,如果你发现内存不足和挂起发生得比较频繁,你首先应该检查是否有非SQL Server的其他应用或者服务耗费了比SQL Server更加多的内存。如果你发现这些应用或者服务,尝试移到别的服务器。如果做不到,那么需要增加更多的内存,以供SQLServer使用。

    如果服务器仅仅工SQL Server使用且没有上面说的情况,那么要分析你的查询和索引,以确保他们是最优化的。如果已经优化好,还是存在这些问题,那么才需要考虑增加内存。

    除了可靠性和性能监视器,还可以使用SQL Server Profiler来监控性能,创建一个用户自定义收集器并存为文件,当你从性能监视器中获取性能数据时,SQL Server Profiler会同步运行。一旦你完成收集,可以把性能数据导入到SQLServer Profiler中供任何时候分析。

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
Explain the InnoDB Buffer Pool and its importance for performance.Explain the InnoDB Buffer Pool and its importance for performance.Apr 19, 2025 am 12:24 AM

InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

MySQL vs. Other Programming Languages: A ComparisonMySQL vs. Other Programming Languages: A ComparisonApr 19, 2025 am 12:22 AM

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages ​​such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages ​​have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

Learning MySQL: A Step-by-Step Guide for New UsersLearning MySQL: A Step-by-Step Guide for New UsersApr 19, 2025 am 12:19 AM

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.

MySQL: Essential Skills for Beginners to MasterMySQL: Essential Skills for Beginners to MasterApr 18, 2025 am 12:24 AM

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL: Structured Data and Relational DatabasesMySQL: Structured Data and Relational DatabasesApr 18, 2025 am 12:22 AM

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL: Key Features and Capabilities ExplainedMySQL: Key Features and Capabilities ExplainedApr 18, 2025 am 12:17 AM

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

The Purpose of SQL: Interacting with MySQL DatabasesThe Purpose of SQL: Interacting with MySQL DatabasesApr 18, 2025 am 12:12 AM

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

MySQL for Beginners: Getting Started with Database ManagementMySQL for Beginners: Getting Started with Database ManagementApr 18, 2025 am 12:10 AM

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA

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 Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.