SQL Server Myths and Misconceptions

Similar documents
High Availability- Disaster Recovery 101

High Availability- Disaster Recovery 101

Microsoft SQL Server Database Administration

Course Outline: Designing, Optimizing, and Maintaining a Database Administrative Solution for Microsoft SQL Server 2008

Designing Database Solutions for Microsoft SQL Server (465)

SQL Server 2014 Training. Prepared By: Qasim Nadeem

DESIGNING DATABASE SOLUTIONS FOR MICROSOFT SQL SERVER CERTIFICATION QUESTIONS AND STUDY GUIDE

SQL Server DBA Course Content

Synergetics-Standard-SQL Server 2012-DBA-7 day Contents

ORACLE 11gR2 DBA. by Mr. Akal Singh ( Oracle Certified Master ) COURSE CONTENT. INTRODUCTION to ORACLE

Administering Microsoft SQL Server Databases

Oracle Database 11g for Experienced 9i Database Administrators

Designing, Optimizing, and Maintaining a Database Administrative Solution for Microsoft SQL Server 2008

Eternal Story on Temporary Objects

ADMINISTERING MICROSOFT SQL SERVER CERTIFICATION QUESTIONS AND STUDY GUIDE

Administering Microsoft SQL Server 2012/2014 Databases

MS SQL Server 2012 DBA Course Contents

Course 6231A: Maintaining a Microsoft SQL Server 2008 Database

Are AGs A Good Fit For Your Database? Doug Purnell

70-459: Transition Your MCITP: Database Administrator 2008 or MCITP: Database Developer 2008 to MCSE: Data Platform

New England Data Camp v2.0 It is all about the data! Caregroup Healthcare System. Ayad Shammout Lead Technical DBA

Course 6231A: Maintaining a Microsoft SQL Server 2008 Database

Maintaining a Microsoft SQL Server 2005 Database Course 2780: Three days; Instructor-Led

Get the Skinny on Minimally Logged Operations

Microsoft SQL Server" 2008 ADMINISTRATION. for ORACLE9 DBAs

Maintaining a Microsoft SQL Server 2008 Database (Course 6231A)

Microsoft Administering Microsoft SQL Server 2014 Databases

6 Months Training Module in MS SQL SERVER 2012

CONFIGURING SQL SERVER FOR PERFORMANCE LIKE A MICROSOFT CERTIFIED MASTER

Basics of Database Corruption Repair

Exam 1Z0-061 Oracle Database 12c: SQL Fundamentals

COURSE 20462C: ADMINISTERING MICROSOFT SQL SERVER DATABASES

Oracle 1Z0-053 Exam Questions & Answers

Memory may be insufficient. Memory may be insufficient.

Designing Database Solutions for Microsoft SQL Server 2012

Microsoft Exam Designing Database Solutions for Microsoft SQL Server Version: 12.0 [ Total Questions: 111 ]

MS-20462: Administering Microsoft SQL Server Databases

Number: Passing Score: 800 Time Limit: 120 min File Version:

Projects. Corporate Trainer s Profile. CMM (Capability Maturity Model) level Project Standard:- TECHNOLOGIES

EXAM Administering Microsoft SQL Server 2012 Databases. Buy Full Product.

The DBA Survival Guide for In-Memory OLTP. Ned Otter SQL Strategist

Optimizing tempdb Performance

How to be a Great Production DBA

Index. Peter A. Carter 2016 P.A. Carter, SQL Server AlwaysOn Revealed, DOI /

1Z Upgrade Oracle9i/10g to Oracle Database 11g OCP Exam Summary Syllabus Questions

Microsoft Administering Microsoft SQL Server 2012/2014 Databases. Download Full version :

Experiences of Global Temporary Tables in Oracle 8.1

SQL Server DBA Course Details

20462: Administering Microsoft SQL Server 2014 Databases

Error code. Description of the circumstances under which the problem occurred. Less than 200. Linux system call error.

Seminar 3. Transactions. Concurrency Management in MS SQL Server

Course Description. Audience. Prerequisites. At Course Completion. : Course 40074A : Microsoft SQL Server 2014 for Oracle DBAs

2072 : Administering a Microsoft SQL Server 2000 Database

The safer, easier way to help you pass any IT exams. Exam : Designing Database Solutions for Microsoft SQL Server 2012.

Avoiding the Cost of Confusion: SQL Server Failover Cluster Instances versus Basic Availability Group on Standard Edition

Microsoft Provisioning SQL Databases (beta)

SQL Server DBA Online Training

1Z Upgrade to Oracle Database 12cm Exam Summary Syllabus Questions

MCTS: SQL Server 2008 Implementation and Maintenance

Designing Database Solutions for Microsoft SQL Server 2012

Designing Database Solutions for Microsoft SQL Server 2012

Course 40045A: Microsoft SQL Server for Oracle DBAs

Developing SQL Databases (762)

AlwaysOn Availability Groups: Backups, Restores, and CHECKDB

Into into Locking and Blocking. Dmitri Korotkevitch ( 1

MySQL High Availability. Michael Messina Senior Managing Consultant, Rolta-AdvizeX /

Oracle Database 10g: New Features for Administrators Release 2

Q&As. TS:MS SQL Server 2008,Implementation and Maintenance. Pass Microsoft Exam with 100% Guarantee

Manual Trigger Sql Server 2008 Update Inserted Rows

Scale out Read Only Workload by sharing data files of InnoDB. Zhai weixiang Alibaba Cloud

CXS-203-1I Citrix XenServer 6.0 Administration

Physical Storage Media

Oracle Database 11g: SQL Fundamentals I

Microsoft SQL Server

Training 24x7 DBA Support Staffing. Administering a SQL Database Infrastructure (40 Hours) Exam

Oracle Architectural Components

IBM DB2 11 DBA for z/os Certification Review Guide Exam 312

CHAPTER 3 RECOVERY & CONCURRENCY ADVANCED DATABASE SYSTEMS. Assist. Prof. Dr. Volkan TUNALI

Build ETL efficiently (10x) with Minimal Logging

DO NOT USE Microsoft Designing Database Solutions for Microsoft SQL Server

Explore the Oracle 10g database architecture. Install software with the Oracle Universal Installer (OUI)

CO MySQL for Database Administrators

Turbo-Charged Transaction Logs. David Maxwell

Microsoft MCSE Exam

Microsoft Exchange Server 2007 Implementation and Maintenance

Real world SQL 2016 In-Memory OLTP

Ryan Adams Blog - Twitter Thanks to our Gold Sponsors

Administering Microsoft SQL Server 2014 Databases

SearchWinIT.com SearchExchange.com SearchSQLServer.com

Troubleshooting Always On Availability Groups Performance

Hardware Intel Core I5 and above 4 GB RAM LAN Connectivity 500 MB HDD (Free Space)

Course Outline. [ORACLE PRESS] All-in-One Course for the OCA/OCP Oracle Database 12c Exams 1Z0-061, 1Z0-062, & 1Z

Course Outline. [ORACLE PRESS] All-in-One Course for the OCA/OCP Oracle Database 12c Exams 1Z0-061, 1Z0-062, & 1Z

Course Outline. SQL Server Performance & Tuning For Developers. Course Description: Pre-requisites: Course Content: Performance & Tuning.

Exam Code: Exam Name: Administering a SQL Database Infrastructure (beta)

Slide 1. Slide 2 Housekeeping. Slide 3 Overview or Agenda

Replication is the process of creating an

Exam Prep Seminar Package: Oracle Database 12c Administrator Certified Associate

Outline. Failure Types

Module 15: Managing Transactions and Locks

Transcription:

SQL Server Myths and Misconceptions Victor Isakov victor@sqlserversolutions.com.au Copyright by Victor Isakov

Abstract As a DBA you have heard of plenty of myths and misconceptions about SQL Server. From how "you can improve transaction log performance with instant file initialisation" to whether "non-logged operations still exist in SQL Server". In this session Victor Isakov will go through over 30 different myths and misconceptions about SQL Server and explain what actually happens in the background. This should be a great session to both test your SQL Server knowledge and to learn how to best administer and configure SQL Server.

Speaker Victor Isakov is a Database Architect / Trainer / SQL Ranger who provides consulting and training services to various organizations in the public, private and NGO sectors globally, and been involved in different capacities at various international events and conferences. Victor specializes in: Still does high-end SQL Server training Performance tuning and optimization Health-checks / Risk Assessments / review of SQL Server infrastructure Architecting / re-factoring database solutions Assessing the effectiveness of your outsourced services / licensing Consolidating / upgrading SQL Server infrastructure Blog: www.victorisakov.com Email: victor@sqlserversolutions.com.au Website: www.sqlserversolutions.com.au

Training Victor Isakov is only Microsoft Certified Trainer in the world who is also a Microsoft Certified Master and a Microsoft Certified Architect and a Microsoft Valuable Professional Differentiation: Trained SQL Server since version 6.0 Has been consulting in SQL Server technology stack Various organisations in public, private and NGO sectors From short-term projects (weeks) to long-terms project (2 years) Wrote / designed some of the Microsoft Official Curriculum Wrote / designed / validated the SQL Server exams Wrote a number of books on SQL Server What does this mean? Offers what we strongly believe is the best SQL training in Asia / Pacific Leverage over a decade of experience Leverage in-depth technical knowledge Knows Microsoft certification and exams in depth Running the DBA course in late-february / early-march

Agenda Why? Myths / Misconception Vote Facts Background Tips Be careful of SQL Server versions We are concentrating on SQL Server 2005+

Why? Lots of myths / misconceptions out there Lead to bad practices Wasted time and resources Confusion Water cooler arguments

Database Snapshots When creating a database snapshot the database engine creates a copy of the entire database Database snapshots use NTFS sparse file technology Space is not reserved Tip: Can cause DBCC CHECKDB to fail Use copy-on-write technology

Suspect Databases You can repair a SUSPECT database by detaching and attaching it In SQL Server 2008+ you cannot detach a suspect database In SQL Server 2000 there was one state Suspect Crash recovery can t run In SQL Server 2005+ there are 2 states Recovery pending Database was not cleanly shut down Suspect Crash recovery started but could not finish

Database Backups When performing a backup you can cause blocking Backups do not take locks Database performance can degrade due to I/O contention

Instant File Initialization Instant file initialization is available in Enterprise Edition only Available in all SKUs of SQL Server

Instant File Initialization Instant file initialization applies to both database and transaction log files Instant file initialization does not apply to transaction log files Database engine needs to zero-out the transaction log file for integrity purposes

Instant File Initialization Configuration Instant file initialization (IFI) can be configured (configured) from SQL Server (NOT REALLY) Windows right SE_MANAGE_VOLUME_NAME Through xp_cmdshell Can control behaviour Trace flag 1806 disables IFI temporarily Transparent Database Encryption (TDE) Tip: Trace Flag 3004 (+3605) writes to errorlog

Online Index Operations Online index operations do not acquire locks Two locks held by online index operations Share table lock acquired at start New empty index (in-build) created Schema version (minor) modified to invalidate existing query plans Schema-Modification lock held at end Drop old index Schema version (major) modified Both locks can cause blocking No locks are acquired / held during index creation Tip: For true 24/7 shops might have to use REORGANIZE

STOPAT Restore Option You can use WITH STOPAT when restoring a full or differential backup TRUE Can use it Does nothing

DBCC CHECKDB DBCC CHECKDB causes blocking within database DBCC CHECKDB uses database snapshots in SQL Server 2005+

FILLFACTOR FILLFACTOR is used by DML operations (INSERTs, UPDATEs, DELETEs) FILLFACTOR only applies during index builds and index rebuilds Tip: FILLFACTOR 0 == FILLFACTOR 100

Lock Escalation Lock escalation goes from row-level to pagelevel to table-level Lock escalation always goes to table-level Row-level -> table-level Page-level -> table-level SQL Server 2008 introduced partition-level lock Tip: can control lock type at table / index level

Rebuilding Clustered Indexes Rebuilding a clustered index always rebuilds all nonclustered indexes SQL Server 2005+ retains the same uniquifier value for non-unique clustered index keys

Database Mirroring Failure A failure is instantaneously detected in database mirroring Mirror pings Princpal every 1 second Mirroring partner timeout defaults 10 seconds I/O completion failure After 20 seconds write to ERRORLOG After 40 seconds take database offline Depends on failure: SQL Server instance crashes Windows crashes Log drive Corrupt page

Database Mirroring Failover A database mirroring failover occurs instantaneously Automatic failover only happens the mirrroring partnership is SYNCHRONIZED and quorum is formed Depends Failover detection Mirror s redo queue Tip: Don t forget to monitor the REDO queue

Nonclustered Indexes A nonclustered index should be created on every column in a table Check sys.dm_db_index_usage_stats to see whether an index is being used Seeks Scans

Failover Clustering Failover clustering is the best High-Availability technology to use Failover clustering has no redundancy at disk I/O subsystem Depends on business RPO RTO Performance overhead Budget

Database Backups A full database backup clears the transaction log Only a log backup clears the transaction log when in FULL or BULK_LOGGED recovery model When in SIMPLE recovery model the CHECKPOINT clears the log

Log Backups You cannot take a concurrent transaction log and database backup You can perform a log backup when a FULL or DIFFERENTIAL backup is being performed in SQL Server 2005+

DMVs You cannot run DMVs against a database in 80 compatibility level Do not support calling functions as a DMV parameter OBJECT_ID(...) Might need to run it from a 90 compatibility level database Use three-part name

Database Corruption You can cause database corruption using a T- SQL statement, or interrupting a T-SQL statement (such as shrinking a database or rebuilding an index)

Point-in-Time Recovery You can restore parts of a database to different points in time Always need to restore to same point in time with piecemeal restores READ_ONLY file groups work differently

Database Versions You can restore or attach a database to an earlier version of SQL Server Physical structure of database different Different transaction log architecture Only solution is to export and import data and code

Database Versions You can restore or attach a database to an earlier version of SQL Server Physical structure of database different Different transaction log architecture Only solution is to export and import data and code

Nested Transactions SQL Server supports nested transactions @@TRANCOUNT increments each time a new BEGIN TRAN is encountered Need to COMMIT TRAN until @@TRANCOUNT reaches 0 Any ROLLBACK TRAN rolls back all nested transactions

FILESTREAM FILESTREAM data can be stored on a network share remote from SQL Server FILESTREAM data container must be local to the SQL Server FILESTREAM data can be accessed remotely

Page Checksums Turning on page checksum immediately protects all pages A page checksum is not generated until if needs to be written back to disk. No tool exists that touches every page in your database Otherwise need to rebuild all indexes But that will not fix allocation pages, system tables, etc You could turn Transparent Database Encryption (TDE) on then off

Avoiding DBCC CHECKDB You can avoid running DBCC CHECKDB as long as you use BACKUP... WITH CHECKSUM A page with corrupt data but a valid checksum can occur The page could be corrupted in memory (Error 832) Rogue process SQL Server bug Faulty memory

Multiple Database Mirrors With database mirroring it is possible to have multiple mirrors of a mirrored database Only one mirror per principal Cannot chain mirrored database Log shipping / replication is the only such solution Tip: Wait for SQL Server ( Denali )

DDL Triggers DDL Triggers are INSTEAD OF triggers Operation is performed and then rolled back

COUNT(*) SELECT COUNT(*) will always use a table scan The query processor needs only to scan the smallest nonclustered index Non-filtered index in SQL Server 2008

Tempdb Size Tempdb should be x% the size of your largest database Depends on many factors Needs to support the largest transaction that occurs on the SQL Server instance

Tempdb Files Tempdb should always have one data file per processor core Trying to alleviate PAGELATCH waits Trace Flag T1118 SQL Server 2005+ has been further optimized Microsoft initially said 1:1 Then seen 1:4 to 1:2 ratio Too many files can also degrade round robin allocation performance

In-flight Transactions In-flight transactions are preserved after a failover in a clustered environment In-flight transaction are not preserved Crash recovery is always involved Uncommited transaction will be rolled back Trace Flag T1118 However... Consider using live-migration / V-motion in a virtual environment

Transaction Log It is not possible to analyse the transaction log using SQL Server DBCC LOG is old school fn_dblog

Transaction Log It is not possible to analyse the transaction log using SQL Server DBCC LOG is old school Use fn_dblog instead Also be aware of fn_dump_dblog Allows you to dump transaction log from a dump backup

Restoring Database Backups You can restore a database backup to an earlier version of SQL Server All depends on physical version of the database Database engine only understands a certain range of physical versions

Fixing Database Corruptions Restarting SQL Server will fix database corruptions Actually that has solved the problem in extremely, extremely, extremely rare and extremely, extremely, extremely luck circumstances Due to stuck I/Os at a SQL Server and I/O subsystem level Not a recommended course of action

Resource Governor Resource Governor allows you to govern I/O Governs memory and processor Query execution memory grants Not buffer pool memory

Q & A Questions? Email: victor@sqlserversolutions.com.au Blog: www.victorisakov.com Website:www.sqlserversolutions.com.au