Managing SQLserver for the reluctant DBA


Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Managing SQLserver for the reluctant DBA

  1. 1. Required Slide<br />
  2. 2. Managing Microsoft SQL Server:For the “Reluctant” DBA<br />Don Jones<br />Senior Partner and Technologist<br />Concentrated Technology, LLC<br />Required Slide<br />SESSION CODE: DAT203<br />
  3. 3. This slide deck was used in one of our many conference presentations. We hope you enjoy it, and invite you to use it within your own organization however you like.<br />For more information on our company, including information on private classes and upcoming conference appearances, please visit our Web site, <br />For links to newly-posted decks, follow us on Twitter:@concentrateddon or @concentratdgreg<br />This work is copyright ©Concentrated Technology, LLC<br />
  4. 4. Introductions<br />Me: Don Jones, Concentrated Technology<br />Microsoft MVP Award recipient<br />Contributing Editor, TechNet Magazine<br />Author of 45+ IT books<br />Blogger at<br />You: The “Microsoft Person” in your environment<br />Not primarily concerned with supporting Microsoft SQL Server…<br />…but more or less forced to do so anyway<br />
  5. 5. Agenda<br />Peeking Under the Hood: How SQL Server Works<br />Backup and Restore Operations<br />About the Query Optimizer<br />Index Maintenance and Tuning<br />Key Database Configuration Options<br />SQL Server Security Model<br />Key Server Configuration Options<br />High Availability and Replication Options<br />
  6. 6. How SQL Server Works, Part 1<br />SQL Server stores data in 8KB chunks called “pages”<br />It always deals with data in these 8KB chunks<br />Generally speaking, all data for a single table row must fit onto a single page<br />It’s actually possible for certain types of data to spread across multiple pages<br />Sometimes, the page can contain a pointer to a file on disk – the FILESTREAM data type<br />The pages live in one or more files (.MDF, .NDF) on disk, but are always read or written in 8KB units<br />
  7. 7. How SQL Server Works, Part 2<br />When a query is issued that results in data being changed, added, or deleted:<br />SQL Server makes a note of the query in its transaction log<br />The database engine determines what page(s) are affected by the change<br />The affected pages are loaded into server memory<br />The changes are made in memory<br /><ul><li>At this stage, the changes have been completed only in RAM.
  8. 8. If something else reads those pages, they’re already handy in memory.</li></li></ul><li>How SQL Server Works, Part 3<br />Eventually, the modified pages are written to disk.<br />When this happens, SQL Server “checks off” the associated query in the transaction log.<br />In the event of a sudden failure:<br />When SQL Server restarts, it looks to see if any “un-checked” queries are in the log.<br />If so, it “re-plays” those queries to bring the database up to speed.<br />If you have the transaction log, you can recover the data!<br />
  9. 9. SQL Server Backups<br />Three types:<br />Full – Backs up the entire database and removes (“truncates”) all “checked” entries from the transaction log<br />Differential: Only what’s changed since the last Full; also truncates the log<br />Transaction log: Only grabs the current transaction log; truncates the active log afterward<br />
  10. 10. Restoring a Database<br />Start with the most recent Full backup<br /><ul><li>Leave the database in “restore mode” if you have other files</li></ul>Apply the most recent differential<br /><ul><li>Stay in “restore mode” if you have more files</li></ul>Apply any transaction logs since the differential was made<br /><ul><li>When finished, allow recovery to begin
  11. 11. Maximum amount of data at-risk: Any changes made since the most recent transaction log backup
  12. 12. Moral: Frequent T-Log backups!</li></li></ul><li>Configuring Backups, Performing Restores<br />DEMO<br />
  13. 13. Indexes<br />Two types:<br />Clustered<br />Every table has one, even if it’s just on the row ID number.<br />Governs the order in which data is logically stored<br />Should be on whatever column is used most for lookups or table joins<br />Non-Clustered<br />Every table can have zero or more<br />Acts as a literal index, keeping entries in order by the indexed column and pointing to the full data row<br />A “covering” index is one that contains entries for every column being queried<br />
  14. 14. Indexes: Pros and Cons<br />Pros<br />Indexes can speed up the time it takes to find data<br />Also speed up sort times<br />Ideally, index on all columns that are frequently used in a WHERE or ORDER BY clause<br />Cons<br />Indexes slow down data add/change/delete operations, because indexes must also be updated<br />Ideally, index nothing<br />The reality is a balancing act: Building indexes on columns that deliver the most benefit, with the least downside<br />
  15. 15. Index Problem: Fragmentation<br />Occurs when index pages become full and data needs to be inserted into the middle<br />A “page split” occurs to make room for the new entry, causing the pages to be “out of order” – this decreases performance<br />NEW!<br />Andrew<br />Andrews<br />Batista<br />Barbara<br />Charles<br />Charlie<br />Frank<br />Gary<br />Grossman<br />Hugh<br />Ina<br />Jack<br />Jackson<br />Jones<br />Kimberly<br />Donavan<br />Eric<br />Erin<br />Derek<br />
  16. 16. Fixing Fragementation<br />Reorganizing or Rebuilding the index will put the entries and pages back into the correct order, improving performance<br />You can specify a “fill factor” that leaves empty space for new entries without splitting pages as often<br />However, emptier pages mean SQL Server has to work harder to read the same amount of data – so this is a balancing act<br />
  17. 17. Rebuilding and Reorganizing Indexes<br />DEMO<br />
  18. 18. Index Tuning<br />The indexes that made sense for a database on day 1 might not make sense after it has been in use for some time<br />You can use SQL Profiler to capture real-world, representative query traffic…<br />…and feed that to the Database Engine Tuning Advisor to get recommendations on index improvements<br />The Advisor can even help you implement those changes that you decide to proceed with<br />
  19. 19. Using the Database Engine Tuning Wizard<br />DEMO<br />
  20. 20. Key Database Options and Best Practices<br />Allow statistics to Auto-Create/Update<br />This makes sure the Query Optimizer knows which indexes exist and what kind of condition they are in<br />Consider disabling auto-growth, or at least monitor it<br />Auto-Grow can consume time; better to manually size the database files appropriately<br />Disable Auto Close except on infrequently-used databases<br />Closed databases incur a performance hit when someone queries them since SQL Server has to open the file<br />
  21. 21. Configuring Key Database Options<br />DEMO<br />
  22. 22. SQL Server Security Model<br />Login: Map to a Windows user/group, or an in-server credential; gets you access to the server<br />Server Role: Contains logins, and defines server-wide privileges<br />Database user: Maps to a login, and gets you into a database<br />Database Role: Contains database users, and defines in-database privileges<br />Custom Database Role: Same as the built-in ones, but you define the permissions<br />App Role: Shortcut login+databaseuser+permissions designed to be activated by an application that defines its own security layer for the data.<br />
  23. 23. Server Options<br />Authentication Mode: “Windows” or “Windows+SQL Server”<br />Memory and Processor options (typically, leave alone)<br />Instances<br />Each “instance” is an independent installation of SQL Server<br />Has its own “server-wide” options (“instance-wide” is a better term)<br />Default instance: Connect using server name<br />Other instances: Connect using SERVERINSTANCE format<br />Review list of services to see instances – each instance has its own SQL Server service<br />
  24. 24. Configuring Key Server and Security Options<br />DEMO<br />
  25. 25. High Availability Options<br />Log Shipping<br />Database Mirroring<br />Windows Clustering<br />
  26. 26. Where to Set Up Database Mirroring<br />DEMO<br />
  27. 27. Replication Options<br />Snapshot<br />Transactional<br />Transactional with Updating Subscribers<br />Merge<br />Off-Topic: Microsoft Sync Framework / Sync Services for ADO.NET<br />
  28. 28. Final Thoughts<br />SQL Server Agent (and Jobs, Operators, and Alerts)<br />Multi-Server Admininstration<br />
  29. 29. Agent, Jobs, and Multi-Server Administration<br />DEMO<br />
  30. 30. Conclusion<br />A few basic admin skills can help you perform the most often-needed SQL Server tasks<br />Keep in mind that the SQL Server Management Studio can connect to multiple servers for single-seat administration<br />
  31. 31. Track Resources<br />Required Slide <br />Track PMs will supply the content for this slide, which will be inserted during the final scrub. <br />Resource 1<br />Resource 2<br />Resource 3<br />Resource 4<br />
  32. 32. Resources<br />Required Slide<br />Learning<br />Sessions On-Demand & Community<br />Microsoft Certification & Training Resources<br /><br /><br />Resources for IT Professionals<br />Resources for Developers<br /><br /><br />
  33. 33. Related Content<br />Required Slide<br />Speakers, please list the Breakout Sessions, Interactive Sessions, Labs and Demo Stations that are related to your session.<br />Breakout Sessions (session codes and titles)<br />Interactive Sessions (session codes and titles)<br />Hands-on Labs (session codes and titles)<br />Product Demo Stations (demo station title and location)<br />
  34. 34. Required Slide<br />Complete an evaluation on CommNet and enter to win!<br />
  35. 35. © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.<br />The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.<br />
  36. 36. This slide deck was used in one of our many conference presentations. We hope you enjoy it, and invite you to use it within your own organization however you like.<br />For more information on our company, including information on private classes and upcoming conference appearances, please visit our Web site, <br />For links to newly-posted decks, follow us on Twitter:@concentrateddon or @concentratdgreg<br />This work is copyright ©Concentrated Technology, LLC<br />