Home Database Mysql Tutorial DBA基础系列SQL Server 2014:2. SQL Server用户数据库初始化配置

DBA基础系列SQL Server 2014:2. SQL Server用户数据库初始化配置

Jun 07, 2016 pm 05:22 PM
microsoft initialization Microsoft database

前言开始前先黑微软一把:Microsoft秉承一贯的简单易用作风(Next、Next、Next…)这点是它吸引用户的地方,但是这个优点如果用在数据库上将是一场灾难,如我们

前言

开始前先黑微软一把:Microsoft秉承一贯的简单易用作风(Next、Next、Next… )这点是它吸引用户的地方,但是这个优点如果用在数据库上将是一场灾难,如我们上一章讲到的SQL Server安装部署,很多人都只知道下一步下一步下一步,但是从来没有考虑过安装向导给出这么多参数配置意义何在,同样的大家习惯了安装完SQL Server后直接使用的方式基本上不去考虑用户数据库初始配置,随着业务量不断攀升,数据量几何倍数的递增,然后发现SQL Server越来越慢,但是又各种无解,最后得出一个结论SQL Server只能满足中小企业需要,但是真实的情况是这样吗?答案当然是否定的【传闻纳斯达克核心数据库原始数据量约2PB现已经转到SQL 2014上了】视频地址

下面我将给到大家一些基本配置和思路让大家的用户数据库在未来数据量增长到TB、PB时依然可以有的放矢的去优化性能满足业务需求

当然这个仅仅是根据我的经验进行探讨,实际情况怎么搭配大家仁者见仁智者见智

无论如何还是要重申一句:本文观点仅代表个人经验,如有不足请大家补充,本文内容如果在实际生产中遇到问题不负任何责任,使用前请先自行论证,最权威的资源请查阅微软官方资料库MSDN,TechNet,官方Blog以及官方技术白皮书等

关于数据库文件场景一:新建数据库

这种情况进行优化最为轻松,优化成本最低

实施步骤:

1. 业务分析,回答自己几个基本问题:

业务涉及的表:

哪些表是数据活跃表:

哪些表是数据惰性表:

cur T.NAMESYS.INDEXES cur=0curcur

将上述T-SQL打印出来的语句Copy到新查询器里面批量执行即可

然后再针对遗留在原始文件组中的那些非聚集索引导出其脚本,批量指定新文件组名字然后DROP,再CREATE

最后原始文件基本上都空了,这时候进行一次数据文件收缩,也就是几秒钟的事情了,至此底层数据整理完成

P.S.其实大家可以看出重整数据文件的过程并不是想象中那么复杂,理清思路产生一大堆脚本,然后扔到Job里面慢慢执行自己就可以提前下班吃饭了

【DBA的工作内容其实还是蛮愉快的:90%以上时间都是在等,等脚本执行,等问题发生,最关键的是等老板发工资;如果一家公司DBA每天都很忙要么是DBA能力不够,要么就是公司或老板有问题】


场景二交易型项目:

交易型项目比数据仓库要复杂一些,不过基本上也是使用上述脚本修修改改就能快速完成

需要注意的地方:主键、外键、约束(尤其是自增约束等)

如果有这些特殊情况就需要有针对性的逐步分析逐步迁移了,这时候就需要先理出一个优先级列表慢慢处理

关于数据库参数

数据库参数也是比较重要的一个环节,尤其是SQL 2000退役,SQL 2005停止主流支持、SQL 2008即将停止主流支持,大量的数据库需要升级到更高版本

数据库兼容级别

在帮助客户进行性能问题分析的时候我留意了一下,很多升级上来的数据库基本上数据库兼容级别都没有修改,这个是需要注意的

SQL Server一般情况默认向下兼容3个主流版本,是为了防止由于版本升级导致用户使用的早期语法或特殊的系统视图出现错误而给予的缓冲机会,并不是说大家在已经升级到高版本后还是继续使用老版本的特性

CHECKSUM

这个参数一般是由于从SQL 2000升级上来时候没有重新配置导致,

SQL 2000的时候还只能简单的检查一下数据页头和定义,无法检查数据页是否真的正常

建议升级上来的所有数据库都去检查一下这个并设置为CHECKSUM

image

自动维护

自动关闭数据库:这个参数类似于Oracle关闭时仅发出shutdown命令,它会等待所有会话结束后关闭数据库,一般情况我们都会用到immediate要求立即结束和关闭

自动创建统计信息:这个最好是开启,SQL执行依赖的执行计划,执行计划评估执行成本就是根据统计信息来的,所以这个相当重要,不是特殊情况应该保持常开

自动收缩数据库:个人从来就很诧异这个参数,如此耗费性能又没有实际价值的一个参数有存在的意义吗?如果不是特殊原因这个参数应该始终关闭

自动更新统计信息:这个参数同自动创建统计信息是一样的,强烈建议常开,统计信息收集越准SQL执行选择的执行计划就会越优,,性能也就越好

自动异步更新统计信息:这个参数建议设置为开启,我们知道统计信息非常重要,但是如果每次数据变化都去收集一次统计信息这个性能也就不那么好了,这个又再次体现了【平衡】

image

更多优化内容(下一章详解):

以上内容各个版本数据库都适用,下列内容将针对特殊版本使用

数据压缩:

适用版本:SQL Server 2008及其以后

非聚集列存储索引:

适用版本:SQL Server 2012及其以后

聚集列存储索引:

适用版本:SQL Server 2014及其以后

本文出自 “Fast” 博客,请务必保留此出处

Statement of this Website
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

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)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Microsoft's full-screen pop-up urges Windows 10 users to hurry up and upgrade to Windows 11 Microsoft's full-screen pop-up urges Windows 10 users to hurry up and upgrade to Windows 11 Jun 06, 2024 am 11:35 AM

According to news on June 3, Microsoft is actively sending full-screen notifications to all Windows 10 users to encourage them to upgrade to the Windows 11 operating system. This move involves devices whose hardware configurations do not support the new system. Since 2015, Windows 10 has occupied nearly 70% of the market share, firmly establishing its dominance as the Windows operating system. However, the market share far exceeds the 82% market share, and the market share far exceeds that of Windows 11, which will be released in 2021. Although Windows 11 has been launched for nearly three years, its market penetration is still slow. Microsoft has announced that it will terminate technical support for Windows 10 after October 14, 2025 in order to focus more on

Microsoft releases Win11 August cumulative update: improving security, optimizing lock screen, etc. Microsoft releases Win11 August cumulative update: improving security, optimizing lock screen, etc. Aug 14, 2024 am 10:39 AM

According to news from this site on August 14, during today’s August Patch Tuesday event day, Microsoft released cumulative updates for Windows 11 systems, including the KB5041585 update for 22H2 and 23H2, and the KB5041592 update for 21H2. After the above-mentioned equipment is installed with the August cumulative update, the version number changes attached to this site are as follows: After the installation of the 21H2 equipment, the version number increased to Build22000.314722H2. After the installation of the equipment, the version number increased to Build22621.403723H2. After the installation of the equipment, the version number increased to Build22631.4037. The main contents of the KB5041585 update for Windows 1121H2 are as follows: Improvement: Improved

Microsoft plans to phase out NTLM in Windows 11 in the second half of 2024 and fully shift to Kerberos authentication Microsoft plans to phase out NTLM in Windows 11 in the second half of 2024 and fully shift to Kerberos authentication Jun 09, 2024 pm 04:17 PM

In the second half of 2024, the official Microsoft Security Blog published a message in response to the call from the security community. The company plans to eliminate the NTLAN Manager (NTLM) authentication protocol in Windows 11, released in the second half of 2024, to improve security. According to previous explanations, Microsoft has already made similar moves before. On October 12 last year, Microsoft proposed a transition plan in an official press release aimed at phasing out NTLM authentication methods and pushing more enterprises and users to switch to Kerberos. To help enterprises that may be experiencing issues with hardwired applications and services after turning off NTLM authentication, Microsoft provides IAKerb and

Samsung will provide displays for Microsoft's MR headsets, and the devices are expected to be lighter and have clearer displays Samsung will provide displays for Microsoft's MR headsets, and the devices are expected to be lighter and have clearer displays Aug 10, 2024 pm 09:45 PM

Recently, Samsung Display and Microsoft signed an important cooperation agreement. According to the agreement, Samsung Display will develop and supply hundreds of thousands of OLEDoS panels for mixed reality (MR) head-mounted devices to Microsoft. Microsoft is developing an MR device for multimedia content such as games and movies. This device is expected to It will be launched after the OLEDoS specifications are finalized, mainly serving the commercial field, and is expected to be delivered as early as 2026. OLEDoS (OLED on Silicon) technology OLEDoS is a new display technology that deposits OLED on a silicon substrate. Compared with traditional glass substrates, it is thinner and has higher pixels. OLEDoS display and ordinary display

Microsoft launches new Windows 11 AI PC: equipped with innovative 'review' function Microsoft launches new Windows 11 AI PC: equipped with innovative 'review' function Jun 06, 2024 pm 01:52 PM

According to news on May 21, Microsoft announced to the public a new Windows PC product-Windows 11 AI PC at a grand event held in its new campus today. This new product is specially designed for AI experience. Windows 11 AI PC is equipped with excellent performance and intelligent design, aiming to provide users with a more intelligent and efficient computing experience. This product will use artificial intelligence technology to achieve a more humane interaction method and bring users the ultimate user experience. At the same time, Windows 11 AI PC also integrates many intelligent functions. Ruzhi Windows 11 AI can provide a major highlight for PC users, namely its unique "Recall" function. This unprecedented "memory"

Detailed tutorial on establishing a database connection using MySQLi in PHP Detailed tutorial on establishing a database connection using MySQLi in PHP Jun 04, 2024 pm 01:42 PM

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos Jul 18, 2024 am 05:48 AM

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

Microsoft releases Android beta version of Microsoft Designer: AI technology helps personalized design Microsoft releases Android beta version of Microsoft Designer: AI technology helps personalized design Jun 28, 2024 pm 10:09 PM

According to news on September 12, Microsoft recently released the Android beta version of Microsoft Designer on Google Play Store, which marks that this new design tool is gradually expanding its applicable platforms. Microsoft Designer will be unveiled as early as October 2022. Its core feature is the integration of generative AI technology, allowing users to easily generate various pictures and conduct personalized designs based on text descriptions. An important feature of Microsoft Designer is the AI ​​painting tool DALL-E2 developed by OpenAI. This tool quickly creates images based on text commands entered by the user. For example, the user simply enters "girl in Christmas costume", D

See all articles