Blue Collar SQL Tricks - Make Standard Edition Work for you. ~ Wolf ~ This template can be used as a starter file for presenting training materials in a group setting. Sections Right-click on a slide to add sections. Sections can help to organize your slides or facilitate collaboration between multiple authors. Notes Use the Notes section for delivery notes or to provide additional details for the audience. View these notes in Presentation View during your presentation. Keep in mind the font size (important for accessibility, visibility, videotaping, and online production) Coordinated colors Pay particular attention to the graphs, charts, and text boxes. Consider that attendees will print in black and white or grayscale. Run a test print to make sure your colors work when printed in pure black and white and grayscale. Graphics, tables, and graphs Keep it simple: If possible, use consistent, non-distracting styles and colors. Label all graphs and tables.
Resources to use: #sqlsatBham #sqlhelp #sqlserver Add slides to each topic section as necessary, including slides with tables, graphs, and images. See next section for sample table, graph, image, and video layouts. #sqlsatBham #sqlhelp #sqlserver
About Wolf DBA for 17 years At RDX for over 6 years. “Manager – SQL Server Performance Tuning” Works with a variety of clients and challenges Give a brief overview of the presentation. Describe the major focus of the presentation and why it is important. Introduce each of the major topics. To provide a road map for the audience, you can repeat this Overview slide throughout the presentation, highlighting the particular topic you will discuss next.
http://25.media.tumblr.com/tumblr_m1mnb7CvtP1rrr8v1o1_1280.jpg
What We Will Focus On 1 2 3 Back to Basics Buffer Pool Extension Partitioned Views 3 Filtered Statistics/Indexes 4 This is another option for an Overview slide.
Configuration Basics Min/Max Memory Tempdb Sizing/Configuration For <= 8 cores, Tempdb data files = # of cores For > 8 cores, 8 Tempdb data files Hyper-Threading Logical hyper-thread CPUs appear as physical CPUs to the operating system Instant File Initialization Faster data growth by NOT zeroing out the file http://www.jwjonline.net/art/SteelWorker.jpg
Normalization First Normal Form (1NF) No repeating groups of information(nothing “;” or “,” delimited) Second Normal Form (2NF) The truth, the whole truth and nothing but the truth Third Normal Form (3NF) Remove groups not dependent on the primary key Boyce-Codd Normal Form(BCNF) A 3NF table that does not have multiple overlapping candidate keys is guaranteed to be in BCNF https://www.patriotsoftware.com/files/images/female%20construction%20worker-resized-600.JPG
Buffer Pool Extension What is the buffer pool? SQL Server is a memory hog When a query is run the pages are loaded in memory, all subsequent calls which need this page would be read from Buffer Pool – this would avoid disk IO and hence improve performance. Data cache scanned periodically. If there is memory pressure, if the page was not accessed on the last two scans, the pages is removed from memory In SQL Server 2014/2016 Standard, the maximum memory usage is 128GB In SQL Server 2008R2 and 2012 it is 64GB Buffer Pool Extensions provide a way of expanding a server’s buffer pool capacity by taking advantage of flash storage While the performance won’t comparable to straight memory, it will out perform standard disk reads. The size of the buffer pool extension can be up to 4 times the max_server_memory value for Standard edition http://pathwaytoaus.com/wp-content/uploads/2014/12/mechanic.jpg
BPE Disabled Spinning Disk Min 2GB Max 5GB
BPE Disabled Spinning Disk Min 500MB Max 750MB
BPE Enabled Spinning Disk Min 500MB Max 750MB
BPE Disabled on SSD Min 2GB Max 5GB
Partitioned Views A form of poor man’s partitioning Partitioned views allow the data in a large table to be split into smaller member tables. The data is partitioned between the member tables based on ranges of data values in one of the columns. Each table must have a check constraint on the range value column The view is created with “UNION ALL” between the tables Query optimizer uses the CHECK constraint definitions to determine which member table contains the rows View is updateable as long as the partitioning column is part of the primary key To perform updates on a partitioned view, the partitioning column must be a part of the primary key of the base table. If a view is not updatable, you can create an INSTEAD OF trigger on the view that allows updates. You should design error handling into the trigger to make sure that no duplicate rows are inserted. For an example of an INSTEAD OF trigger designed on a view, see Designing INSTEAD OF Triggers. CHECK constraints are not needed for the partitioned view to return the correct results. However, if the CHECK constraints have not been defined, the query optimizer must search all the tables instead of only those that cover the search condition on the partitioning column. Without the CHECK constraints, the view operates like any other view with UNION ALL. The query optimizer cannot make any assumptions about the values stored in different tables and it cannot skip searching the tables that participate in the view definition. http://image.slidesharecdn.com/enterprisegamificationbluecollarworker-140614164007-phpapp01/95/enterprise-gamification-and-the-blue-collar-worker-3-638.jpg?cb=1402764348
Filtered Statistics Another form of poor man’s partitioning “Where Clause” on the statistics creation Can have up to 30,000 statistics on non-indexed columns Can fix cardinality estimate errors Great for finding out lying values https://s-media-cache-ak0.pinimg.com/originals/d7/48/09/d748098ddc23470c5557240b53ec8ce0.jpg
Filtered Indexes Another form of poor man’s partitioning “Where clause” on the index creation Filtered indexes are great performance boosts if you have a value that is used in a predicate very frequently, but that value is only a small amount of the total values for that table Use equality or inequality operators. Use IN to create an index for a range of values. Multiple filtered indexes on one column There are MANY restrictions https://msdn.microsoft.com/en-us/library/cc280372.aspx#Restrictions http://richmondstandard.com/wp-content/uploads/2015/07/Rosie-the-Riveter.png
Well Now
Resources https://blog.varonis.com/sql-server-best-practices-part-configuration/ http://www.studytonight.com/dbms/database-normalization.php https://msdn.microsoft.com/en-us/library/dn133176.aspx https://technet.microsoft.com/en-us/library/ms190019(v=sql.105).aspx http://logicalread.solarwinds.com/sql-server-memory-buffer-pools-pd01/#.WDuNhfkrKM8 http://www.sqlpassion.at/archive/2013/10/29/fixing-cardinality-estimation-errors-with-filtered-statistics/ https://www.mssqltips.com/sqlservertip/2353/performance-advantages-of-sql-server-filtered-statistics/ http://www.sqlskills.com/blogs/kimberly/filtered-indexes-and-filtered-stats-might-become-seriously-out-of-date/ https://www.brentozar.com/archive/2013/11/what-you-can-and-cant-do-with-filtered-indexes/ https://blogs.msdn.microsoft.com/sqlreleaseservices/sql-server-2016-service-pack-1-sp1-released/
Microsoft Engineering Excellence Questions? Microsoft Confidential