Your SlideShare is downloading. ×
0
Supporting SQL Server – When You ’d Really Rather Not Don Jones ConcentratedTech.com Pre-requisites for this presentation:...
This slide deck was used in one of our many conference presentations. We hope you enjoy it, and invite you to use it withi...
About the Instructor <ul><li>Don Jones </li></ul><ul><li>Contributing Editor,  technetmagazine.com </li></ul><ul><li>IT au...
About this Session <ul><li>Primarily  demo and how-to… not so much with the slides </li></ul><ul><li>Most queries  I run I...
About You <ul><li>A Windows admin stuck managing one or more SQL Server installs because you ’re “the Microsoft guy/gal” <...
SUPPORTING SQL SERVER <ul><li>Part 1 </li></ul>
How SQL Server Works <ul><li>Database  is a logical+physical structure – think of it as a container </li></ul><ul><li>Cont...
Physical Storage <ul><li>SQL stores data in database files (MDF, NDF) </li></ul><ul><li>Organized into 8KB pages, which ho...
Filestreams <ul><li>New in SQL2008: Ability to store large data in normal files outside the database, and only keep a poin...
Querying Data <ul><li>SQL Server loads needed pages into memory to access their data </li></ul><ul><li>Uses a  query optim...
Changing Data <ul><li>SQL Server loads affected pages into RAM </li></ul><ul><li>Changes pages in RAM and logs the change ...
Committing Data <ul><li>When SQL writes affected pages back to disk, it  “marks” them as “committed” in the log </li></ul>...
Recovery Mode <ul><li>SQL Server automatically starts in recovery mode </li></ul><ul><li>It checks to see if any uncommitt...
Backup Model <ul><li>Full Backup: All of the data. Clears ( ‘truncates’) committed transactions from the log – because now...
Backup Example <ul><li>1am: Full backup </li></ul><ul><li>9am: Incremental </li></ul><ul><li>10am: Log </li></ul><ul><li>1...
Tips <ul><li>Keep logs on separate disks/volumes from the data </li></ul><ul><li>Backup to a file, and then grab the backu...
Performance <ul><li>When new objects (tables, etc) are created in the database, you can designate which file they go to </...
Indexes <ul><li>Help SQL Server find sorted data faster </li></ul><ul><li>Each table can have one  clustered  index – phys...
Index Fragmentation (Page Splits) <ul><li>Happens when a page is full, and SQL needs to insert data  “in between” existing...
Index Maintenance <ul><li>Periodically rebuild/reorganize indexes </li></ul><ul><li>Can specify amount of free space to le...
Index Tricks <ul><li>An index can contain more than one column </li></ul><ul><li>A  covering index  is one which contains ...
Non-Covering Index <ul><li>SELECT Name,ID FROM Users WHERE Name LIKE  ‘D%’ </li></ul>CI NCI ID Name 4 Erin 5 Don 6 Dave Da...
Covering Index <ul><li>SELECT Name FROM Users WHERE Name LIKE  ‘D%’ </li></ul>CI NCI ID Name 4 Erin 5 Don 6 Dave Dave Don ...
Index Downsides <ul><li>Indexes improve lookup speeds, but diminish write speeds </li></ul><ul><li>Indexes have to be upda...
SQL Index Wizards <ul><li>Help analyze database usage and suggest useful indexes that can be added </li></ul><ul><li>Also ...
Getting SQL Traffic <ul><li>SQL Profiler lets you capture traffic to a file or database </li></ul><ul><li>Run Profiler, an...
Understanding Query Execution Plans <ul><li>A  plan  is generated by the Query Optimizer and is a game plan for how to con...
Hints and Reused Plans <ul><li>SQL will cache execution plans for a short time and re-use them </li></ul><ul><li>But the c...
High Availability Options <ul><li>Windows Clustering </li></ul><ul><li>Database Mirroring (w/Witness) </li></ul><ul><li>Tr...
Instances <ul><li>SQL is designed to run multiple copies of itself in parallel </li></ul><ul><li>Called  instances </li></...
Security <ul><li>Security is configured first as the instance level: Windows or Mixed authentication (determines type of l...
Permissions <ul><li>Permissions assigned via membership in  roles  (in-SQL groups, basically) or via direct permissions </...
More Fun <ul><li>Let ’s look at database options and discuss what they do </li></ul><ul><li>Discuss user databases in SQL ...
More Resources <ul><li>Drop off a business card (or your e-mail address) and Greg Shields and I will send you our decks an...
THE SQL LANGUAGE <ul><li>PART 2 </li></ul>
How We ’ll Proceed <ul><li>Most of this will be done as demos. </li></ul><ul><li>I ’ll make the queries available as downl...
Major Language Elements <ul><li>Queries </li></ul><ul><li>SELECT: Get Data </li></ul><ul><li>INSERT: Add Data </li></ul><u...
Thank You! <ul><li>Please feel free to pick up a card if you ’d like copies of my session materials </li></ul><ul><li>I ’l...
 
This slide deck was used in one of our many conference presentations. We hope you enjoy it, and invite you to use it withi...
Upcoming SlideShare
Loading in...5
×

Supporting SQLserver

389

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
389
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
12
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • MGB 2003 © 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
  • MGB 2003 © 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
  • MGB 2003 © 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
  • Transcript of "Supporting SQLserver"

    1. 1. Supporting SQL Server – When You ’d Really Rather Not Don Jones ConcentratedTech.com Pre-requisites for this presentation: 1) Strong understanding of basic Windows administration Level: Advanced
    2. 2. 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. For more information on our company, including information on private classes and upcoming conference appearances, please visit our Web site, www.ConcentratedTech.com . For links to newly-posted decks, follow us on Twitter: @concentrateddon or @concentratdgreg This work is copyright ©Concentrated Technology, LLC
    3. 3. About the Instructor <ul><li>Don Jones </li></ul><ul><li>Contributing Editor, technetmagazine.com </li></ul><ul><li>IT author, consultant, and speaker </li></ul><ul><li>Co-founder of Concentrated Technology </li></ul><ul><li>Seven-time recipient of Microsoft ’s Most Valuable Professional (MVP) Award </li></ul><ul><li>Author and Editor-in-Chief for Realtime Publishers </li></ul><ul><li>Trainer for www.CBTNuggets.com </li></ul>
    4. 4. About this Session <ul><li>Primarily demo and how-to… not so much with the slides </li></ul><ul><li>Most queries I run I will save (remind me) – I ’ll make these available on my Web site (see slide at end of deck) for you to download, along with this deck </li></ul>
    5. 5. About You <ul><li>A Windows admin stuck managing one or more SQL Server installs because you ’re “the Microsoft guy/gal” </li></ul><ul><li>Not particularly interested in SQL Server </li></ul><ul><li>Just stuck running it </li></ul>
    6. 6. SUPPORTING SQL SERVER <ul><li>Part 1 </li></ul>
    7. 7. How SQL Server Works <ul><li>Database is a logical+physical structure – think of it as a container </li></ul><ul><li>Contains one or more tables , which represent entities that an application works with </li></ul><ul><li>Tables consist of columns and rows – kinda like an Excel spreadsheet </li></ul>
    8. 8. Physical Storage <ul><li>SQL stores data in database files (MDF, NDF) </li></ul><ul><li>Organized into 8KB pages, which hold 1+ rows of data each </li></ul><ul><li>An entire row must always fit on a page; large data chunks may be spread across multiple pages </li></ul>
    9. 9. Filestreams <ul><li>New in SQL2008: Ability to store large data in normal files outside the database, and only keep a pointer in the database </li></ul><ul><li>Shares the files via a normal file share </li></ul><ul><li>Impacts some features such as database mirroring and certain forms of replication </li></ul>
    10. 10. Querying Data <ul><li>SQL Server loads needed pages into memory to access their data </li></ul><ul><li>Uses a query optimizer to analyze incoming queries and decide the best way to get the needed data </li></ul><ul><li>Optimizer relies on internal statistics that tell it the physical condition of the data (fragmentation level, etc) </li></ul>
    11. 11. Changing Data <ul><li>SQL Server loads affected pages into RAM </li></ul><ul><li>Changes pages in RAM and logs the change to a transaction log (LDF file) </li></ul><ul><li>Doesn ’t write the affected pages back to disk immediately </li></ul><ul><li>Log serves as a form of bakcup </li></ul>
    12. 12. Committing Data <ul><li>When SQL writes affected pages back to disk, it “marks” them as “committed” in the log </li></ul><ul><li>It does not clear the from the log </li></ul>
    13. 13. Recovery Mode <ul><li>SQL Server automatically starts in recovery mode </li></ul><ul><li>It checks to see if any uncommitted transactions are in any logs </li></ul><ul><li>If it finds them, it re-runs the transactions and commits them immediately </li></ul><ul><li>This deals with “we had uncommitted data in RAM and the server crashed” </li></ul>
    14. 14. Backup Model <ul><li>Full Backup: All of the data. Clears ( ‘truncates’) committed transactions from the log – because now they’re safe </li></ul><ul><li>Incremental: Everything since the last full or incremental </li></ul><ul><li>Log: Backs up just the log file </li></ul>
    15. 15. Backup Example <ul><li>1am: Full backup </li></ul><ul><li>9am: Incremental </li></ul><ul><li>10am: Log </li></ul><ul><li>11am: Log </li></ul><ul><li>11:05: CRASH </li></ul><ul><li>Restore the full, the incremental, both logs </li></ul><ul><li>Will lose everything from 11:00-11:05 </li></ul><ul><li>Log backups are VERY fast </li></ul>
    16. 16. Tips <ul><li>Keep logs on separate disks/volumes from the data </li></ul><ul><li>Backup to a file, and then grab the backup file to tape – or use an agent to backup directly to tape </li></ul><ul><li>SQL itself can also backup directly to tape for locally-attached tape drives </li></ul>
    17. 17. Performance <ul><li>When new objects (tables, etc) are created in the database, you can designate which file they go to </li></ul><ul><li>One MDF file per database, multiple NDF files </li></ul><ul><li>Spread files across disks to improve access times </li></ul><ul><li>Backup/restore the files as a unit by having all files in the same filegroup </li></ul>
    18. 18. Indexes <ul><li>Help SQL Server find sorted data faster </li></ul><ul><li>Each table can have one clustered index – physically stores data in the desired order </li></ul><ul><li>Can have 1+ nonclustered indexes – pointers to the actual physical data </li></ul><ul><li>Indexes are also stored on 8KB pages </li></ul>
    19. 19. Index Fragmentation (Page Splits) <ul><li>Happens when a page is full, and SQL needs to insert data “in between” existing data </li></ul><ul><li>The page is split: Half the data is copied to a new page at the end of the data file, making room for the new data </li></ul><ul><li>Results in index fragmentation </li></ul>
    20. 20. Index Maintenance <ul><li>Periodically rebuild/reorganize indexes </li></ul><ul><li>Can specify amount of free space to leave – leaves room for growth w/out splits </li></ul><ul><li>Allow SQL to auto-update statistics – helps it understand how useful each index is on a continuing basis </li></ul>
    21. 21. Index Tricks <ul><li>An index can contain more than one column </li></ul><ul><li>A covering index is one which contains all the data needed to satisfy a query – without having to go to the actual data </li></ul>
    22. 22. Non-Covering Index <ul><li>SELECT Name,ID FROM Users WHERE Name LIKE ‘D%’ </li></ul>CI NCI ID Name 4 Erin 5 Don 6 Dave Dave Don Erin
    23. 23. Covering Index <ul><li>SELECT Name FROM Users WHERE Name LIKE ‘D%’ </li></ul>CI NCI ID Name 4 Erin 5 Don 6 Dave Dave Don Erin
    24. 24. Index Downsides <ul><li>Indexes improve lookup speeds, but diminish write speeds </li></ul><ul><li>Indexes have to be updated </li></ul><ul><li>Always a compromise between read and write performance </li></ul>
    25. 25. SQL Index Wizards <ul><li>Help analyze database usage and suggest useful indexes that can be added </li></ul><ul><li>Also suggests indexes that can be removed </li></ul><ul><li>Ideal when used with production-quality traffic </li></ul>
    26. 26. Getting SQL Traffic <ul><li>SQL Profiler lets you capture traffic to a file or database </li></ul><ul><li>Run Profiler, and capture to, a different machine than the one you are profiling </li></ul><ul><li>Great way to troubleshoot and to gather “real” traffic for tuning wizards </li></ul>
    27. 27. Understanding Query Execution Plans <ul><li>A plan is generated by the Query Optimizer and is a game plan for how to conduct the query </li></ul><ul><li>Specifies what indexes will be used, etc </li></ul><ul><li>Can be viewed graphically or as XML; XML plans can be saved and re-used (bad idea) </li></ul>
    28. 28. Hints and Reused Plans <ul><li>SQL will cache execution plans for a short time and re-use them </li></ul><ul><li>But the condition of the database is always changing – a good plan today may be a bad plan tomorrow </li></ul><ul><li>Applying manual “hints” or forcing plan re-use often results in good performance short-term, worse long-term </li></ul>
    29. 29. High Availability Options <ul><li>Windows Clustering </li></ul><ul><li>Database Mirroring (w/Witness) </li></ul><ul><li>Transaction Log Shipping </li></ul>
    30. 30. Instances <ul><li>SQL is designed to run multiple copies of itself in parallel </li></ul><ul><li>Called instances </li></ul><ul><li>Each instance is a complete install of the product </li></ul><ul><li>One default instance, multiple named instances </li></ul><ul><li>SQL Express installs a named instance by default </li></ul>
    31. 31. Security <ul><li>Security is configured first as the instance level: Windows or Mixed authentication (determines type of logins allowed) </li></ul><ul><li>Logins grant access to the server </li></ul><ul><li>Logins map to in-database users , which grant access to databases </li></ul>
    32. 32. Permissions <ul><li>Permissions assigned via membership in roles (in-SQL groups, basically) or via direct permissions </li></ul><ul><li>Each DB object is owned by a particular user </li></ul><ul><li>Permissions chaining says SQL only checks permissions on an owner change </li></ul>
    33. 33. More Fun <ul><li>Let ’s look at database options and discuss what they do </li></ul><ul><li>Discuss user databases in SQL Express </li></ul><ul><li>Discuss attaching/detaching databases </li></ul><ul><li>Discuss misc. SQL Server components: Reporting, Integration, Analysis </li></ul>
    34. 34. More Resources <ul><li>Drop off a business card (or your e-mail address) and Greg Shields and I will send you our decks and other class materials (scripts, samples, etc) </li></ul><ul><li>Visit http://ConcentratedTech.com for free, daily technical articles, Q&A, step-by-step guides, and much more </li></ul><ul><li>Want my “USB Go Pack?” It’s a 4GB USB key stuffed with video clips, white papers, step-by-step guides, articles, and much more – available only here for $60. </li></ul>
    35. 35. THE SQL LANGUAGE <ul><li>PART 2 </li></ul>
    36. 36. How We ’ll Proceed <ul><li>Most of this will be done as demos. </li></ul><ul><li>I ’ll make the queries available as downloads for you </li></ul><ul><li>I ’ll also detach the sample database and include that for you </li></ul><ul><ul><li>Note: Most of the sample data will be created on-the-fly – makes it easier to see what data is coming from where </li></ul></ul><ul><li>Slide at the end will have the address </li></ul>
    37. 37. Major Language Elements <ul><li>Queries </li></ul><ul><li>SELECT: Get Data </li></ul><ul><li>INSERT: Add Data </li></ul><ul><li>UPDATE: Change Data </li></ul><ul><li>DELETE: Remove Data </li></ul><ul><li>Clauses </li></ul><ul><li>WHERE </li></ul><ul><li>ORDER BY </li></ul><ul><li>TOP </li></ul><ul><li>Aggregate expressions </li></ul><ul><li>GROUP BY / HAVING </li></ul><ul><li>UNION </li></ul><ul><li>JOIN </li></ul>
    38. 38. Thank You! <ul><li>Please feel free to pick up a card if you ’d like copies of my session materials </li></ul><ul><li>I ’ll be happy to take any last questions while I pack up </li></ul><ul><li>Please complete and submit an evaluation form for this and every session you attend! </li></ul>
    39. 40. 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. For more information on our company, including information on private classes and upcoming conference appearances, please visit our Web site, www.ConcentratedTech.com . For links to newly-posted decks, follow us on Twitter: @concentrateddon or @concentratdgreg This work is copyright ©Concentrated Technology, LLC
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×