Database Administration for the Non-DBA

Slides:



Advertisements
Similar presentations
Tuning: overview Rewrite SQL (Leccotech)Leccotech Create Index Redefine Main memory structures (SGA in Oracle) Change the Block Size Materialized Views,
Advertisements

Denny Cherry Manager of Information Systems MVP, MCSA, MCDBA, MCTS, MCITP.
Chris Ruel * Image used without permission.
Big Data Working with Terabytes in SQL Server Andrew Novick
FlareCo Ltd ALTER DATABASE AdventureWorks SET PARTNER FORCE_SERVICE_ALLOW_DATA_LOSS Slide 1.
DataBase Administration Scheduling jobs Backing up and restoring Performing basic defragmentation and index rebuilding Using alerts Archiving.
SQL Server Best Practices Keep Your Database In Top Performance Shape and Maintain Effective Backups September, 2007 Richard Kokoski.
©2006 ITT Educational Services Inc. Course Name: IT390 Business Database Administration Unit 5 Slide 1 IT390 Business Database Administration Unit 5 :
Database Optimization & Maintenance Tim Richard ECM Training Conference#dbwestECM Agenda SQL Configuration OnBase DB Planning Backups Integrity.
Fundamentals, Design, and Implementation, 9/e Chapter 11 Managing Databases with SQL Server 2000.
Backup, Integrity Check and Index and Statistics Maintenance
Backup Concepts. Introduction Backup and recovery procedures protect your database against data loss and reconstruct the data, should loss occur. The.
Denny Cherry twitter.com/mrdenny.
SQL Server 2008 Implementation and Maintenance Chapter 7: Performing Backups and Restores.
Troubleshooting SQL Server Enterprise Geodatabase Performance Issues
It is one of the techniques to create a stand by server. Introduced in SQL 2000,enhanced in It is a High Availability as well as Disaster recovery.
Chapter 18: Windows Server 2008 R2 and Active Directory Backup and Maintenance BAI617.
Databases Lesson 5.
Architecture Rajesh. Components of Database Engine.
SQL Server Indexes Indexes. Overview Indexes are used to help speed search results in a database. A careful use of indexes can greatly improve search.
Table Indexing for the.NET Developer Denny Cherry twitter.com/mrdenny.
Module 16: Performing Ongoing Database Maintenance
1 CS 430 Database Theory Winter 2005 Lecture 16: Inside a DBMS.
Denny Cherry twitter.com/mrdenny.
Denny Cherry
Denny Cherry twitter.com/mrdenny.
Week 7 : Chapter 7 Agenda SQL 710 Maintenance Plan:
SQL/Lesson 7/Slide 1 of 32 Implementing Indexes Objectives In this lesson, you will learn to: * Create a clustered index * Create a nonclustered index.
SQL SERVER DAYS 2011 Table Indexing for the.NET Developer Denny Cherry twitter.com/mrdenny.
IMS 4212: Database Implementation 1 Dr. Lawrence West, Management Dept., University of Central Florida Physical Database Implementation—Topics.
Denny Cherry
SQL SERVER DAYS 2011 Indexing Internals Denny Cherry twitter.com/mrdenny.
Unit-8 Introduction Of MySql. Types of table in PHP MySQL supports various of table types or storage engines to allow you to optimize your database. The.
Praveen Srivatsa Director| AstrhaSoft Consulting blogs.asthrasoft.com/praveens |
Retele de senzori Curs 2 - 1st edition UNIVERSITATEA „ TRANSILVANIA ” DIN BRAŞOV FACULTATEA DE INGINERIE ELECTRICĂ ŞI ŞTIINŢA CALCULATOARELOR.
Log Shipping, Mirroring, Replication and Clustering Which should I use? That depends on a few questions we must ask the user. We will go over these questions.
October 15-18, 2013 Charlotte, NC Accelerating Database Performance Using Compression Joseph D’Antoni, Solutions Architect Anexinet.
Digging Out From Corruption Eddie Wuerch, MCM - Principal, Database Performance - Salesforce Marketing Cloud Data protection and loss recovery with SQL.
Backing Up and Restoring Databases Advanced Database Dr. AlaaEddin Almabhouh.
Module 6: Creating and Maintaining Indexes. Overview Creating Indexes Understanding Index Creation Options Maintaining Indexes Introducing Statistics.
Microsoft SQL is known as RDMS (Relational Database Management System) which is developed by Microsoft and is highly used at corporate and enterprise.
You Inherited a Database Now What? What you should immediately check and start monitoring for. Tim Radney, Senior DBA for a top 40 US Bank President of.
Database Administration for the Non-DBA Denny Cherry twitter.com/mrdenny.
Doing fast! Optimizing Query performance with ColumnStore Indexes in SQL Server 2012 Margarita Naumova | SQL Master Academy.
Agenda for Today  DATABASE Definition What is DBMS? Types Of Database Most Popular Primary Database  SQL Definition What is SQL Server? Versions Of SQL.
SQL IMPLEMENTATION & ADMINISTRATION Indexing & Views.
You Inherited a Database Now What?
Automated Restore Script Output for Ola Hallengren’s Maintenance Solution 1) Start SQL Services on Local 2) Connect to Azure AlwaysOn 3) Delete all maintenance.
Managing Multi-User Databases
Physical Changes That Don’t Change the Logical Design
Indices.
BASIC INFORMATION ABOUT DATABASE MANAGEMENT SOFTWARE
Finding more space for your tight environment
Designing Database Solutions for SQL Server
The Nitty-Gritty of Database Backups
Introduction to SQL Server Management for the Non-DBA
Optimizing SQL Server Performance in a Virtual Environment
SQL Server May Let You Do It, But it Doesn’t Mean You Should
Table Indexing for the .NET Developer
Understanding and Handling Database Corruption
Backup and Restore your SQL Server Database
Statistics: What are they and How do I use them
Denny Cherry twitter.com/mrdenny
You Inherited a Database Now What?
Clustered Columnstore Indexes (SQL Server 2014)
Chapter 11 Managing Databases with SQL Server 2000
Manipulating Data Lesson 3.
SQL Server Indexing for the Client Developer
Database management systems
Presentation transcript:

Database Administration for the Non-DBA Denny Cherry mrdenny@dcac.co www.dcac.co twitter.com/mrdenny

About Me Denny Cherry & Associates Consulting 6 books Dozens of articles Microsoft MVP Microsoft Certified Master VMware vExpert EMC Elect

Agenda Files, File Groups, Disks Backups Recovery Model Database Maintenance Compression Corruption Compatibility Level Indexes

Files, File Groups, Disks File Groups are made up of files Files hold the data Disks Hold Files http://www.flickr.com/photos/photomequickbooth/4011249096/

Files, File Groups, Disks Each database is made up of at least two files One file is data One file is transaction log The data file contains all of the data within the database. The transaction log contains a record of every change which has been made to the database since the last time the transaction log was truncated. Depending on the recovery model of the database (we’ll talk more about recovery models in a few slides) when the transaction log is cleared will change. There can be multiple data files for a single database, and there can be multiple transaction log files for a database. In some situations having multiple data files can give you a performance increase, however it isn’t needed. I’ve got customers who have multi-terabyte databases which are just a single physical file. There is no performance increase for having multiple transaction log files. There are some edge cases where having multiple transaction log files can be helpful, however in 99.999% of cases there is no need. http://www.flickr.com/photos/photomequickbooth/4011249096/

Backups 3 Different Kinds of Backups Transaction Log Backups Full Backups Differential Backups Transaction Log Backups Advanced Backup Options File Group Backups Backups Saved On Another Machine How often full, differential and transaction log backups should be taken totally depends on how much data you as a company are willing to loose in the event of a major database failure. It is often the case that within a company there will be some databases which you can afford to loose more data from than others. http://www.flickr.com/photos/gemstone/406866312/

Full Backups Makes a point in time copy of the database Database is in the state the database was at the end of the backup Should be done daily or weekly

Recovery Models Simple Bulk-Logged Full Three Recovery Models Available Simple Bulk-Logged Full Used to control amount of logging http://www.flickr.com/photos/decade_null/142235888/

No Point In Time Recovery Simple Recovery Model Minimal Logging No Point In Time Recovery Does Not Disable Logging When the database is in the simple recovery model the transaction log is truncated about once a minute. http://www.flickr.com/photos/noii/1337970464/

Bulk Logged Recovery Model Some commands are bulk logged Most commands are fully logged Point In Time Recovery Supported When the database is in full recovery mode or bulk logged recovery the transaction log will only be cleared when a transaction log backup is completed. http://www.flickr.com/photos/4nitsirk/3778043845/

Full Recovery Full Data Protection Point in time recovery is supported Almost nothing is bulk logged Point in time recovery is supported Full Data Protection http://www.flickr.com/photos/usarmyafrica/5536713055/

Transaction Log Restore Restoring Data Full Restore Differential Restore Transaction Log Restore Page Level Restore File Group Restore The goal when restoring data is to get the database into the exact state that it was at the time when that backup was taken. By using transaction log backups as well as full backups (and if available differential backups) we can restore a database to what ever point in time that we want. A restore operation when using the transaction log can be restored to one thousandth of a second. This allows for very precise control when restoring a database which has had database deleted as you can restore until just before the moment when the data was deleted to ensure that you get every data change until just before the deletion was done. In the event of data corruption (we’ll talk more about data corruption later) you can restore just the data page which has been corrupted by first restoring that page from the full backup, then restoring the transaction log backups. The SQL Server will see that the few pages which are being restored our the only ones which are out of sync with the rest of the database and they will be the only pages which are restored. On large databases restoring just a few database pages will be much faster than restoring the entire database. http://www.flickr.com/photos/fun_flying/2959307155/

Database Maintenance Databases need TLC Index Rebuilding Index Defragmenting Update Statistics http://www.flickr.com/photos/wjlonien/6309343565/

Database Maintenance Index Rebuild Index Defrag Can be online or offline depending on version, edition and column data types Creates new indexes then drops old index Updates Statistics on index Always Online Moves data around pages row by row Only moves rows that need to be moved Online index rebuilds are supported in Enterprise Edition of SQL Server starting in SQL Server 2005. However if a table has blob data types like varchar(max), nvarchar(max), text, ntext, xml, image then online index rebuilding is not supported for that table. This changes in SQL Server 2012 Enterprise edition where blob columns now support online index rebuilding. At the end of the day after doing an index rebuild or an index defrag the end result is the same. The big difference is which method will be faster, based on the amount of fragmentation for that index. http://www.flickr.com/photos/usnavy/5488581781/

Statistics? How SQL Server figures out how to access data Statistics are used to create an execution plan Statistics are a sampling of the values within a table or index Statistics contain up to 200 samples of the values within the table Statistics track the number of values between sampled values http://www.flickr.com/photos/franganillo/3676227162/

Statistics? This output is shown using DBCC SHOW_STATISTICS. The first row shows some basic information about the table and the number of rows which were sampled when the statistic was created. The second recordset shows the columns in the statistic (as well as within the index that the statistic is built on) as well as the average length of these columns. The third recordset shows the ranges of the values which the statistic contains. The RANGE_HI_KEY column contains the value from the first column of the index. The RANGE_ROWS tells you how many rows there are between the value in the RANGE_HI_KEY column and the next value. The EQ_ROWS column tells you how many rows there are in the statistic which have the same value as the RANGE_HI_KEY value. Out of all this information the most important value to look at is the Updated column of the first recordset. This tells you when the last time the statistic was updated. If the table is updated very frequently and performance is inconsistent, and the value in the Updated column is very old, manually updating the statistic might be required.

Compression Saves space within: Costs CPU speed, but usually worth it The database Memory Backups Costs CPU speed, but usually worth it Data Compression is Page or Row Backup Compression is an on or off Data compression is an Enterprise only feature so it is only available when using the Enterprise Edition of SQL Server 2008 and up. Backup Compression was introduced in SQL Server 2008 as an Enterprise Edition feature, but in SQL Server 2008 R2 it was changed to a standard edition feature. http://www.flickr.com/photos/aussiegall/316350537/

Corruption All databases can become corrupt Corruption is usually a hardware problem Corruption should be checked for regularly Depending on what is corrupt it may be repaired without data loss Corruption is checked for and repaired using DBCC CHECKDB Corruption will happen, how you prepare for it will determine how easily you can survive it Some corruption can’t be repaired and must be restored from a backup Starting with SQL Server 7, 99.99% of corruption is problems with the storage (disks, cables, drivers, etc.) 0.005% of corruption is bad RAM. 0.005% of corruption is bugs within SQL Server. http://www.flickr.com/photos/posterboynyc/6321014425/

SQL 2008 R2 and below support SQL 6.5 and up Compatibility Level Compatibility levels tell SQL Server which language syntax to support Does not effect the version of the SQL Server the database can be restored to SQL Supports several down level compatibility levels. SQL 2014 supports SQL 2008 and up SQL 2012 supports SQL 2005 and up SQL 2008 R2 and below support SQL 6.5 and up http://www.flickr.com/photos/eyesplash/4121161376/

Indexes Used to speed up queries Sorted based on the columns within the index Causes duplicate data to be stored Trades space for speed Indexes are ½ art and ½ science An index is sort of like the card catalog in the library. If we imagine that each book in the library is a row within a table, we need a way to find the right book. Most libraries have two card catalogs, one sorted by book name and one sorted by author name. Each of these card catalogs would be an index within the database. If you want to find the book called “Securing SQL Server” you would search through the index which is based on book titles looking for the matching book. If you wanted to find books written by me “Denny Cherry” you would search the author index in order to find my name. In either case using the index will be much faster than scanning through the database table looking for the correct row. http://www.flickr.com/photos/annarbor/4350627292/

Indexes Clustered Nonclustered Full Text Spatial ColumnStore XML Semantic Search These are a few of the different kinds of indexing available within SQL Server. 99% of the time non-clustered indexes will be what you are creating. When creating nonclusterered indexes the indexed columns should be the columns within the WHERE clause with any additional columns such as the columns in the SELECT statement being put into the index as included columns. http://www.flickr.com/photos/tryingyouth/2456237/

Indexes Based on this query, returning the FirstName and LastName columns and searching based on the LastName column we would want to create an index that looks like {click} this index.

Indexes Starting in SQL Server 2008 indexes can be filtered. This makes the indexes shorter as we can exclude rows from the index that we know will never be needed by our queries. Looking at a similar query, this time only looking for active employees with the last name of Cherry, when we create our index we can include only the rows which have the value of 1 in the Active column by adding a WHERE Clause to our index {click} like this. Now filtered indexes aren’t appropriate in every situation, but in some cases they can be very handy to use.

Indexes Indexes aren’t free Every index added slows down INSERT/UPDATE/DELETE operations Only create indexes where the cost of having the index is worth it Unused indexes can be removed from the database

Additional Reading… http://dcac.co/res/ive-got-a-database

I’ve Got a SQL Database, Now What? Denny Cherry mrdenny@dcac.co www.dcac.co twitter.com/mrdenny