SQL Server MVP Volume 2

SQL Server MVP Volume 2

MANNING DEEP DIVES Volume 2 EDITED BY Kalen Delaney Louis Davidson Greg Low Brad McGehee Paul Nielsen Paul Randal Kimberly Tripp MVP AUTHORS Johan Åhlén ● Gogula Aryalingam ● Glenn Berry ● Aaron Bertrand ● Kevin G. Boles ● Robert Cain ● Tim Chapman ● Denny Cherry ● Michael Coles ● Rod Colledge John Paul Cook ● Louis Davidson ● Rob Farley ● Grant Fritchey ● Darren Gosbell ● Sergio Govoni ● Allan Hirt ● Satya Jayanty ● Tibor Karaszi ● Jungsun Kim ● Tobiasz Koprowski ● Hugo Kornelis ● Ted Krueger ● Matija Lah ● Greg Low ● Rodney Landrum ● Greg Larsen ● Peter Larsson ● Andy Leonard ● Ami Levin ● John Magnabosco Jennifer McCown ● Brad McGehee ● Siddharth Mehta ● Ben Miller ● Allan Mitchell ● Tim Mitchell ● Luciano Moreira ● Jessica Moss ● Shahriar Nikkhah ● Paul Nielsen Robert Pearl ● Boyan Penev ● Pedro Perfeito ● Pawel Potasinski ● Mladen Prajdi c´ ● Abolfazl Radgoudarzi ● Denis Reznik ● Rafael Salas ● Edwin Sarmiento Chris Shaw ● Gail Shaw ● Linchi Shea ● Jason Strate ● Paul Turley ● William Vaughn ● Peter Ward ● Joe Webb ● John Welch ● Allen White ● Thiago Zavaschi The authors of this book support the children of Operation Smile SQL Server MVP Deep Dives Volume 2 SQL Server MVP Deep Dives Volume 2 Edited by Kalen Delaney ■ Louis Davidson ■ Greg Low Brad McGehee ■ Paul Nielsen ■ Paul Randal ■ Kimberly Tripp MANNING SHELTER ISLAND For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact Special Sales Department Manning Publications Co. 20 Baldwin Road PO Box 261 Shelter Island, NY 11964 Email: [email protected] ©2012 by Manning Publications Co. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps. Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without the use of elemental chlorine. Development editor: Cynthia Kane Manning Publications Co. Copyeditor: Liz Welch, Linda Recktenwald 20 Baldwin Road Project editor: Barbara Mirecki PO Box 261 Typesetter: Marija Tudor Shelter Island, NY 11964 Cover designer: Marija Tudor ISBN 9781617290473 Printed in the United States of America 1 2 3 4 5 6 7 8 9 10 – MAL – 16 15 14 13 12 11 To all the children of Operation Smile MVP authors and their chapters Johan Åhlén 53 Jennifer McCown 37 Gogula Aryalingam 57 Brad McGehee 36 Glenn Berry 31 Siddharth Mehta 60 Aaron Bertrand 19 Ben Miller 26 Kevin G. Boles 20 Allan Mitchell 59 Robert Cain 45 Tim Mitchell 51 Tim Chapman 38 Luciano Moreira 27 Denny Cherry 5 Jessica M. Moss 40 Michael Coles 46 Paul Nielsen 6 Rod Colledge 14 Shahriar Nikkhah 48 John Paul Cook 21 Robert Pearl 34 Louis Davidson 4 Boyan Penev 55 Rob Farley 2 Pedro Perfeito 58 Grant Fritchey 32 Pawel Potasinski 12 Darren Gosbell 54 Mladen Prajdic´ 28 Sergio Govoni 22 Abolfazl Radgoudarzi 48 Allan Hirt 7 Denis Reznik 29 Satya Jayanty 16 Rafael Salas 52 Tibor Karaszi 17 Edwin Sarmiento 44 Jungsun Kim 39 Chris Shaw 3 Tobiasz Koprowski 18 Gail Shaw 8 Hugo Kornelis 23 Linchi Shea 35 Ted Krueger 50 Jason Strate 33 Matija Lah 24 Paul Turley 43 Rodney Landrum 15 William Vaughn 42 Greg Larsen 9 Peter Ward 13 Peter Larsson 25 Joe Webb 10 Andy Leonard 47 John Welch 49 Ami Levin 1 Allen White 30 Greg Low 41 Thiago Zavaschi 56 John Magnabosco 11 vii brief contents PART 1 ARCHITECTURE ............................................... 1 1 ■ Where are my keys? 3 2 ■ “Yes, we are all individuals” A look at uniqueness in the world of SQL 16 3 ■ Architectural growth pains 26 4 ■ Characteristics of a great relational database 37 5 ■ Storage design considerations 49 6 ■ Generalization: the key to a well-designed schema 60 PART 2 DATABASE ADMINISTRATION .......................... 65 7 ■ Increasing availability through testing 67 8 ■ Page restores 79 9 ■ Capacity planning 87 10 ■ Discovering your servers with PowerShell and SMO 95 11 ■ Will the real Mr. Smith please stand up? 105 12 ■ Build your own SQL Server 2008 performance dashboard 111 13 ■ SQL Server cost recovery 121 14 ■ Best practice compliance with Policy-Based Management 128 15 ■ Using SQL Server Management Studio to the fullest 138 16 ■ Multiserver management and Utility Explorer—best tools for the DBA 146 ix x BRIEF CONTENTS 17 ■ Top 10 SQL Server admin student misconceptions 157 18 ■ High availability of SQL Server in the context of Service Level Agreements 167 PART 3 DATABASE DEVELOPMENT............................ 175 19 ■ T-SQL: bad habits to kick 177 20 ■ Death by UDF 185 21 ■ Using regular expressions in SSMS 195 22 ■ SQL Server Denali: what’s coming next in T-SQL 200 23 ■ Creating your own data type 211 24 ■ Extracting data with regular expressions 223 25 ■ Relational division 234 26 ■ SQL FILESTREAM: to BLOB or not to BLOB 245 27 ■ Writing unit tests for Transact-SQL 255 28 ■ Getting asynchronous with Service Broker 267 29 ■ Effective use of HierarchyId 278 30 ■ Let Service Broker help you scale your application 287 PART 4 PERFORMANCE TUNING AND OPTIMIZATION .... 297 31 ■ Hardware 201: selecting and sizing database server hardware 299 32 ■ Parameter sniffing: your best friend…except when it isn’t 309 33 ■ Investigating the plan cache 320 34 ■ What are you waiting for? An introduction to waits and queues 331 35 ■ You see sets, and I see loops 343 36 ■ Performance-tuning the transaction log for OLTP workloads 353 37 ■ Strategies for unraveling tangled code 362 38 ■ Using PAL to analyze SQL Server performance 374 39 ■ Tuning JDBC for SQL Server 384 PART 5 BUSINESS INTELLIGENCE .............................. 395 40 ■ Creating a formal Reporting Services report part library 397 BRIEF CONTENTS xi 41 ■ Improving report layout and visualization 405 42 ■ Developing sharable managed code expressions in SSRS 411 43 ■ Designing reports with custom MDX queries 424 44 ■ Building a scale-out Reporting Services farm 436 45 ■ Creating SSRS reports from SSAS 448 46 ■ Optimizing SSIS for dimensional data loads 457 47 ■ SSIS configurations management 469 48 ■ Exploring different types of enumerators in the SSIS Foreach Loop container 480 49 ■ Late-arriving dimensions in SSIS 494 50 ■ Why automate tasks with SSIS? 503 51 ■ Extending SSIS using the Script component 515 52 ■ ETL design checklist 526 53 ■ Autogenerating SSAS cubes 538 54 ■ Scripting SSAS databases – AMO and PowerShell, Better Together 548 55 ■ Managing context in MDX 557 56 ■ Using time intelligence functions in PowerPivot 569 57 ■ Easy BI with Silverlight PivotViewer 577 58 ■ Excel as a BI frontend tool 585 59 ■ Real-time BI with StreamInsight 597 60 ■ BI solution development design considerations 608 contents preface xxxv acknowledgments xxxix about Operation Smile xli about this book xliii about the editors xlv about SQL Server MVPs xlvi PART 1 ARCHITECTURE ................................................ 1 EDITED BY LOUIS DAVIDSON Where are my keys? 3 1 AMI LEVIN Keys in the relational model 4 The debate 5 The arguments 6 Pro artificial keys 6 ■ Pro natural keys 8 Additional considerations 10 Natural keys assist the optimizer 11 ■ Artificial keys are the de facto standard 12 ■ Modularity, portability, and foreseeing the future 12 IDENTITY columns may result in value gaps and “run out” of values 13 Recommendations 13 Simplicity and aesthetics 14 Summary 14 xiii xiv CONTENTS “Yes, we are all individuals” 2 A look at uniqueness in the world of SQL 16 ROB FARLEY Introducing uniqueness 16 Constrained to uniqueness 16 Primary keys 17 ■ Unique constraints 18 ■ Unique indexes 19 Unique constraint or unique index? 19 Advantages of the unique index 19 ■ Advantages of the unique constraint 20 Uniqueness in results 20 The good and the bad of DISTINCT 20 ■ DISTINCT or GROUP BY 21 ■ Are they needed at all? 22 ■ Unnecessary grouping 23 Being guided by “that” error 24 Summary 25 Architectural growth pains 26 3 CHRIS SHAW Manage your data types 27 IDENTITY case in point 27 ■ Database design and scalability 28 Naming conventions 28 Inconsistent design 29 Normalization 30 Overnormalized 30 ■ Undernormalized 30 Primary keys and foreign keys 31 GUIDs as primary keys 31 ■ System-generated integers as primary keys 32 ■ Generating your own ID values 32 Indexes 33 Underindexing 33 ■ Overindexing 35 ■ Maintenance 35 Fill factor 36 Summary 36 Characteristics of a great relational database 37 4 LOUIS DAVIDSON Coherent 38 Standards based 38 ■ Reasonable names and data types 39 Cohesive 40 ■ Needs little documentation 40 CONTENTS xv Normal 40 Fundamentally sound 41 Documented 42 Secure 43 Encapsulated 44 Well performing 46 Summary 47 Storage design considerations 49 5 DENNY CHERRY Selecting the correct RAID type 49 RAID 0 49 ■ RAID 1 50 ■ RAID 5 51 ■ RAID 6 51 RAID 10 52 ■ RAID 50 52 ■ When to use RAID 5 52 When to use RAID 6 53 ■ When to use RAID 10 53 File placement 53 Index files 54 ■ Transaction log files 54 ■

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    690 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us