2. Managing Microsoft SQL Server:For the “Reluctant” DBA Don Jones Senior Partner and Technologist Concentrated Technology, LLC Required Slide SESSION CODE: DAT203
4. Introductions Me: Don Jones, Concentrated Technology Microsoft MVP Award recipient Contributing Editor, TechNet Magazine Author of 45+ IT books Blogger at http://ConcentratedTech.com You: The “Microsoft Person” in your environment Not primarily concerned with supporting Microsoft SQL Server… …but more or less forced to do so anyway
5. Agenda Peeking Under the Hood: How SQL Server Works Backup and Restore Operations About the Query Optimizer Index Maintenance and Tuning Key Database Configuration Options SQL Server Security Model Key Server Configuration Options High Availability and Replication Options
6. How SQL Server Works, Part 1 SQL Server stores data in 8KB chunks called “pages” It always deals with data in these 8KB chunks Generally speaking, all data for a single table row must fit onto a single page It’s actually possible for certain types of data to spread across multiple pages Sometimes, the page can contain a pointer to a file on disk – the FILESTREAM data type The pages live in one or more files (.MDF, .NDF) on disk, but are always read or written in 8KB units
7.
8.
9. SQL Server Backups Three types: Full – Backs up the entire database and removes (“truncates”) all “checked” entries from the transaction log Differential: Only what’s changed since the last Full; also truncates the log Transaction log: Only grabs the current transaction log; truncates the active log afterward
10.
11. Maximum amount of data at-risk: Any changes made since the most recent transaction log backup
12.
13. Indexes Two types: Clustered Every table has one, even if it’s just on the row ID number. Governs the order in which data is logically stored Should be on whatever column is used most for lookups or table joins Non-Clustered Every table can have zero or more Acts as a literal index, keeping entries in order by the indexed column and pointing to the full data row A “covering” index is one that contains entries for every column being queried
14. Indexes: Pros and Cons Pros Indexes can speed up the time it takes to find data Also speed up sort times Ideally, index on all columns that are frequently used in a WHERE or ORDER BY clause Cons Indexes slow down data add/change/delete operations, because indexes must also be updated Ideally, index nothing The reality is a balancing act: Building indexes on columns that deliver the most benefit, with the least downside
15. Index Problem: Fragmentation Occurs when index pages become full and data needs to be inserted into the middle A “page split” occurs to make room for the new entry, causing the pages to be “out of order” – this decreases performance NEW! Andrew Andrews Batista Barbara Charles Charlie Frank Gary Grossman Hugh Ina Jack Jackson Jones Kimberly Donavan Eric Erin Derek
16. Fixing Fragementation Reorganizing or Rebuilding the index will put the entries and pages back into the correct order, improving performance You can specify a “fill factor” that leaves empty space for new entries without splitting pages as often However, emptier pages mean SQL Server has to work harder to read the same amount of data – so this is a balancing act
18. Index Tuning The indexes that made sense for a database on day 1 might not make sense after it has been in use for some time You can use SQL Profiler to capture real-world, representative query traffic… …and feed that to the Database Engine Tuning Advisor to get recommendations on index improvements The Advisor can even help you implement those changes that you decide to proceed with
20. Key Database Options and Best Practices Allow statistics to Auto-Create/Update This makes sure the Query Optimizer knows which indexes exist and what kind of condition they are in Consider disabling auto-growth, or at least monitor it Auto-Grow can consume time; better to manually size the database files appropriately Disable Auto Close except on infrequently-used databases Closed databases incur a performance hit when someone queries them since SQL Server has to open the file
22. SQL Server Security Model Login: Map to a Windows user/group, or an in-server credential; gets you access to the server Server Role: Contains logins, and defines server-wide privileges Database user: Maps to a login, and gets you into a database Database Role: Contains database users, and defines in-database privileges Custom Database Role: Same as the built-in ones, but you define the permissions App Role: Shortcut login+databaseuser+permissions designed to be activated by an application that defines its own security layer for the data.
23. Server Options Authentication Mode: “Windows” or “Windows+SQL Server” Memory and Processor options (typically, leave alone) Instances Each “instance” is an independent installation of SQL Server Has its own “server-wide” options (“instance-wide” is a better term) Default instance: Connect using server name Other instances: Connect using SERVERNSTANCE format Review list of services to see instances – each instance has its own SQL Server service
30. Conclusion A few basic admin skills can help you perform the most often-needed SQL Server tasks Keep in mind that the SQL Server Management Studio can connect to multiple servers for single-seat administration
31. Track Resources Required Slide Track PMs will supply the content for this slide, which will be inserted during the final scrub. Resource 1 Resource 2 Resource 3 Resource 4
32. Resources Required Slide Learning Sessions On-Demand & Community Microsoft Certification & Training Resources www.microsoft.com/teched www.microsoft.com/learning Resources for IT Professionals Resources for Developers http://microsoft.com/technet http://microsoft.com/msdn
33. Related Content Required Slide Speakers, please list the Breakout Sessions, Interactive Sessions, Labs and Demo Stations that are related to your session. Breakout Sessions (session codes and titles) Interactive Sessions (session codes and titles) Hands-on Labs (session codes and titles) Product Demo Stations (demo station title and location)