search
HomeDatabaseMysql Tutorial2年SQL Server DBA调优方面总结

公告 2年SQL Server DBA调优方面总结 2年SQL Server DBA调优方面总结 当2年dba 我觉得,有些东西需要和大家分享探讨,先书单。 书单 1.《深入解析SQL Server 2008 系列》 这个就是mssql 2005 的技术内幕系列。2012版的也出了有兴趣可以看看,技术内幕系列是

公告

2年SQL Server DBA调优方面总结

2年SQL Server DBA调优方面总结

当2年dba 我觉得,有些东西需要和大家分享探讨,先书单。

书单

1.《深入解析SQL Server 2008 系列》 这个就是mssql 2005 的技术内幕系列。2012版的也出了有兴趣可以看看,技术内幕系列是我接触最早的书,里面内容涵盖量很大,但是都是点到为止。所以很多都是可以细细品味,回头再看的。

2.《Troubleshooting SQL Server A Guide for the Accidental DBA》 这本书是我接触最早的关于性能调优的书。链接已经给出可以去下载,不过需要注册SQLServerCenter ,这个网站是SQL Server 方面比较出名的网站。很多国外大牛。

3.《联机文档》也就是sql server 装机后自带的帮助文档,内容全面的吓人,几乎包含了技术内幕系列的所有内容。

4.《The.Gurus.Guide.To.SQL.Server.Architecture.And.Internals》这本书是将sql server 2000的内核,从软件开发的角度来看SQL Server 2000,很深入作者也十分的出名,可惜死的太早。对sql server框架理解主要来源于这本书,可惜没有中文版。

5.《SQL Server 2008 内核剖析和故障排除》接触的第二本关于性能调优的书,真本书比较绝的地方时,先将原理再讲调优。全书分为2部分第一部分就是原理,第二部分是性能调优。也是不错的一本,书中对扩展事件的功能做了比较详细的解释。我在其他书上是没看到过的。

该书的2012英文原版已经出了。

6.《Microsoft SQL Server企业级平台管理实践》是一本少见的国产好书,书的编写很符合中国人心理,直指问题本身,很适合当工具书。其中有关于性能跟踪调整,从捕获到处理讲的很实际。

7.《SQLSERVER求生秘籍》和《The.Gurus.Guide.To.SQL.Server.Architecture.And.Internals》是同一个作者,这本书主要是针对SQL Server 2005和上一本一样对个别点讲的很深入,缺点讲到的东西太少。

8.《SQL Server 2008查询性能调优》这本书比较实用的一本书,讲了各个瓶颈的发现,性能基线的简历,从查询,存储过程角度出发,分析性能,讲解可能出现性能问题的点。

9.《Pro SQL Server 2008 Service Broker》 讲解关于Service Broker,异步消息处理程序,很多比较大的公司会使用,我知道的是新蛋是使用这个的,全书围绕一个大例子比较清晰,容易接受。

10.《Pro SQL Server 2008 Policy-Based Management》关于策略管理方面的知识,个人觉得比较鸡肋。

 

安全性

楼主是小公司的DBA所以关于安全性使用的比较少,就管理一些权限和密码

可用性

到SQL Server 2012实现了多种可用性方案,1.日志传送,2.数据库复制,3.数据库镜像,4.alwaysonline。

1.日志传送,楼主觉得是数据库镜像的雏形。没有数据库镜像那样试试的传送和redo日志

2.数据库复制,数据库复制有比较多的分类:快照,事务,合并。事务复制是被应用最广的,从sql server 2000到sql server 2005事务复制被改进了很对具体可以看联机文档。

3.数据库镜像,我对于不需要读写分离的数据库中,数据库镜像是被应用最广的可用性方案,数据库镜像和其他的比最突出的优点是切换方便。

高性能

DBA的大头应该是性能调优。性能的调优大头是索引,最求更高的性能索引是必不可少的。一个性能主要体现的执行时间上,执行时间= 运行时间+等待时间。这个公式我觉得很经典。当你没有头绪的时候能帮你梳理清楚应该怎么排查问题。做性能调优一定要对性能的指标十分熟悉。

 

性能基线

当你刚刚入职一家公司,对公司数据库现在的负载一无所知,那么一开始要做的事情就是创建一个数据库性能基线。有人会问基线能用来干什么,很多人感觉没用,我刚入职时我也觉得没用。但是性能基线是一个性能调优,监控的开始。

 

一般比较正规的公司,一个业务上线前会通过压力测试预计这个服务器的性能边境在哪里,到达性能边境之后各个性能指标的表现是如何的。如果如果性能基线接近了性能边界,到了这个时候,那么就要考虑换服务器或者加服务器了。这个是性能基线的一个用处。

 

拿到一个服务器我先会做一下性能基线,网站空间,性能基线也就是服务器在正常运转的时候数据库的性能指标的表现。我会抓取24小时的性能指标作为性能基线(可以看我相关的文章:SQL Server 性能基线和监控,SQL Server 性能调优(性能基线))。

 

以下是我使用的抓取的指标

cpu:

    \Processor(_Total)\% Processor Time
    \Processor(_Total)\% Privileged Time

    \SQLServer:SQL Statistics\Batch Requests/sec
    \SQLServer:SQL Statistics\SQL Compilations/sec
    \SQLServer:SQL Statistics\SQL Re-Compilations/sec
    \System\Processor Queue Length
    \System\Context Switches/sec

  Memory:

    \Memory\Available Bytes
    \Memory\Pages/sec
    \Memory\Page Faults/sec
    \Memory\Pages Input/sec
    \Memory\Pages Output/sec
    \Process(sqlservr)\Private Bytes
    \SQLServer:Buffer Manager\Buffer cache hit ratio
    \SQLServer:Buffer Manager\Page life expectancy
    \SQLServer:Buffer Manager\Lazy writes/sec
    \SQLServer:Memory Manager\Memory Grants Pending
    \SQLServer:Memory Manager\Target Server Memory (KB)
    \SQLServer:Memory Manager\Total Server Memory (KB)

  Disk:

    \PhysicalDisk(_Total)\% Disk Time
    \PhysicalDisk(_Total)\Current Disk Queue Length
    \PhysicalDisk(_Total)\Avg. Disk Queue Length
    \PhysicalDisk(_Total)\Disk Transfers/sec
    \PhysicalDisk(_Total)\Disk Bytes/sec
    \PhysicalDisk(_Total)\Avg. Disk sec/Read
    \PhysicalDisk(_Total)\Avg. Disk sec/Write

  SQL Server:

    \SQLServer:Access Methods\FreeSpace Scans/sec
    \SQLServer:Access Methods\Full Scans/sec
    \SQLServer:Access Methods\Table Lock Escalations/sec
    \SQLServer:Access Methods\Worktables Created/sec
    \SQLServer:General Statistics\Processes blocked
    \SQLServer:General Statistics\User Connections
    \SQLServer:Latches\Total Latch Wait Time (ms)
    \SQLServer:Locks(_Total)\Lock Timeouts (timeout > 0)/sec
    \SQLServer:Locks(_Total)\Lock Wait Time (ms)
    \SQLServer:Locks(_Total)\Number of Deadlocks/sec
    \SQLServer:SQL Statistics\Batch Requests/sec
    \SQLServer:SQL Statistics\SQL Re-Compilations/sec

指标代表啥意思我就不解释了,美国服务器,你可以开perfmon,挨个看说明。

假设你现在已经有了性能指标了,那么你就可以根据性能基线简历告警了,以前的文章(SQL Server 性能基线和监控)中我已经提供了使用powershell如何监控性能。

 

性能运行性能问题分析:

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
How does MySQL index cardinality affect query performance?How does MySQL index cardinality affect query performance?Apr 14, 2025 am 12:18 AM

MySQL index cardinality has a significant impact on query performance: 1. High cardinality index can more effectively narrow the data range and improve query efficiency; 2. Low cardinality index may lead to full table scanning and reduce query performance; 3. In joint index, high cardinality sequences should be placed in front to optimize query.

MySQL: Resources and Tutorials for New UsersMySQL: Resources and Tutorials for New UsersApr 14, 2025 am 12:16 AM

The MySQL learning path includes basic knowledge, core concepts, usage examples, and optimization techniques. 1) Understand basic concepts such as tables, rows, columns, and SQL queries. 2) Learn the definition, working principles and advantages of MySQL. 3) Master basic CRUD operations and advanced usage, such as indexes and stored procedures. 4) Familiar with common error debugging and performance optimization suggestions, such as rational use of indexes and optimization queries. Through these steps, you will have a full grasp of the use and optimization of MySQL.

Real-World MySQL: Examples and Use CasesReal-World MySQL: Examples and Use CasesApr 14, 2025 am 12:15 AM

MySQL's real-world applications include basic database design and complex query optimization. 1) Basic usage: used to store and manage user data, such as inserting, querying, updating and deleting user information. 2) Advanced usage: Handle complex business logic, such as order and inventory management of e-commerce platforms. 3) Performance optimization: Improve performance by rationally using indexes, partition tables and query caches.

SQL Commands in MySQL: Practical ExamplesSQL Commands in MySQL: Practical ExamplesApr 14, 2025 am 12:09 AM

SQL commands in MySQL can be divided into categories such as DDL, DML, DQL, DCL, etc., and are used to create, modify, delete databases and tables, insert, update, delete data, and perform complex query operations. 1. Basic usage includes CREATETABLE creation table, INSERTINTO insert data, and SELECT query data. 2. Advanced usage involves JOIN for table joins, subqueries and GROUPBY for data aggregation. 3. Common errors such as syntax errors, data type mismatch and permission problems can be debugged through syntax checking, data type conversion and permission management. 4. Performance optimization suggestions include using indexes, avoiding full table scanning, optimizing JOIN operations and using transactions to ensure data consistency.

How does InnoDB handle ACID compliance?How does InnoDB handle ACID compliance?Apr 14, 2025 am 12:03 AM

InnoDB achieves atomicity through undolog, consistency and isolation through locking mechanism and MVCC, and persistence through redolog. 1) Atomicity: Use undolog to record the original data to ensure that the transaction can be rolled back. 2) Consistency: Ensure the data consistency through row-level locking and MVCC. 3) Isolation: Supports multiple isolation levels, and REPEATABLEREAD is used by default. 4) Persistence: Use redolog to record modifications to ensure that data is saved for a long time.

MySQL's Place: Databases and ProgrammingMySQL's Place: Databases and ProgrammingApr 13, 2025 am 12:18 AM

MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

MySQL: From Small Businesses to Large EnterprisesMySQL: From Small Businesses to Large EnterprisesApr 13, 2025 am 12:17 AM

MySQL is suitable for small and large enterprises. 1) Small businesses can use MySQL for basic data management, such as storing customer information. 2) Large enterprises can use MySQL to process massive data and complex business logic to optimize query performance and transaction processing.

What are phantom reads and how does InnoDB prevent them (Next-Key Locking)?What are phantom reads and how does InnoDB prevent them (Next-Key Locking)?Apr 13, 2025 am 12:16 AM

InnoDB effectively prevents phantom reading through Next-KeyLocking mechanism. 1) Next-KeyLocking combines row lock and gap lock to lock records and their gaps to prevent new records from being inserted. 2) In practical applications, by optimizing query and adjusting isolation levels, lock competition can be reduced and concurrency performance can be improved.

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools