Maciej Pilecki | Project Botticelli Ltd.. SELECT Bio FROM Speakers WHERE FullName=‘Maciej Pilecki’;  Microsoft Certified Trainer since 2001  SQL Server.

Slides:



Advertisements
Similar presentations
Debugging/Tuning Queries via iSeries Navigator Tom McKinley
Advertisements

Chapter 9. Performance Management Enterprise wide endeavor Research and ascertain all performance problems – not just DBMS Five factors influence DB performance.
Top Tuning Tools for SQL Server Kevin Kline & Aaron Bertrand SQL Sentry.
Cardinality How many rows? Distribution How many distinct values? density How many rows for each distinct value? Used by optimizer A histogram 200 steps.
Database Optimization & Maintenance Tim Richard ECM Training Conference#dbwestECM Agenda SQL Configuration OnBase DB Planning Backups Integrity.
Indexes Rose-Hulman Institute of Technology Curt Clifton.
Module 7: Creating and Maintaining Indexes. Overview Creating Indexes Creating Index Options Maintaining Indexes Introduction to Statistics Querying the.
Passage Three Introduction to Microsoft SQL Server 2000.
Relational Database Performance CSCI 6442 Copyright 2013, David C. Roberts, all rights reserved.
Maintaining a Microsoft SQL Server 2008 Database SQLServer-Training.com.
Maciej Pilecki Consultant, SQL Server MVP Project Botticelli Ltd. SESSION CODE: DAT403.
Computer Science 101 Database Concepts. Database Collection of related data Models real world “universe” Reflects changes Specific purposes and audience.
Understanding SQL Server 2008 Change Data Capture Bret Stateham Training Manager Vortex Learning Solutions blogs.netconnex.com.
Module 16: Performing Ongoing Database Maintenance
1 Chapter Overview Performing Configuration Tasks Setting Up Additional Features Performing Maintenance Tasks.
Microsoft AREC TAM Internship SQL Server Performance Tuning(I) Haijun Yang AREC SQL Support Team Feb, SQL Server 2000.
Query Optimizer Execution Plan Cost Model Joe Chang
© IBM Corporation 2005 Informix User Forum 2005 John F. Miller III Explaining SQLEXPLAIN ®
Chapter 4 Indexes. Index Architecture  By default data is inserted on a first-come, first-serve basis  Indexes bring order to this chaos  Once you.
Session 1 Module 1: Introduction to Data Integrity
Pinal Dave Mentor | Solid Quality India |
SQL Query Analyzer. Graphical tool that allows you to:  Create queries and other SQL scripts and execute them against SQL Server databases. (Query window)
Virtual techdays INDIA │ august 2010 Filtered Indexes – The unexplored index … Vinod Kumar M │ Microsoft India Technology Evangelist – DB and BI.
Maciej Pilecki Consultant Project Botticelli Ltd. DAT404.
SSMS SQL Server Management System. SQL Server Microsoft SQL Server is a Relational Database Management System (RDBMS) Relational Database Management System.
8 Copyright © 2005, Oracle. All rights reserved. Gathering Statistics.
SQL SERVER MAINTENANCE PLANS Kat
SQL Server Statistics DEMO SQL Server Statistics SREENI JULAKANTI,MCTS.MCITP,MCP. SQL SERVER Database Administration.
October 15-18, 2013 Charlotte, NC SQL Server Index Internals Tim Chapman Premier Field Engineer.
Module 6: Creating and Maintaining Indexes. Overview Creating Indexes Understanding Index Creation Options Maintaining Indexes Introducing Statistics.
SQL Server Statistics DEMO SQL Server Statistics SREENI JULAKANTI,MCTS.MCITP SQL SERVER Database Administration.
Database Administration for the Non-DBA Denny Cherry twitter.com/mrdenny.
Doing fast! Optimizing Query performance with ColumnStore Indexes in SQL Server 2012 Margarita Naumova | SQL Master Academy.
Best Practices for Columnstore Indexes Warner Chaves SQL MCM / MVP SQLTurbo.com Pythian.com.
SQL Server Magic Buttons! What are Trace Flags and why should I care? Steinar Andersen, SQL Service Nordic AB Thanks to Thomas Kejser for peer-reviewing.
Data Integrity & Indexes / Session 1/ 1 of 37 Session 1 Module 1: Introduction to Data Integrity Module 2: Introduction to Indexes.
SQL Server Statistics and its relationship with Query Optimizer
Thank You! #sqlsatdnipro Denis
SQL Server Statistics 101 Travis Whitley Senior Consultant, Oakwood Systems whitleysql.wordpress.com.
Finding more space for your tight environment
Parameter Sniffing in SQL Server Stored Procedures
Designing Database Solutions for SQL Server
Reading Execution Plans Successfully
The Top 5 SQL Server Mistakes
SQL Server Optimizing Query Plans
Database Administration for the Non-DBA
Statistics for beginners
Working with Very Large Tables Like a Pro in SQL Server 2014
Statistics And New Cardinality Estimator (CE)
Statistics for beginners
SQL Server 2017 has more cool features than just running on Linux
Hitting the SQL Server “Go Faster” Button
Now where does THAT estimate come from?
Query Optimization Statistics: The Driving Force Behind Good Performance G. Vern Rabe -
Statistics What are the chances
JULIE McLAIN-HARPER LINKEDIN: JM HARPER
Statistics: What are they and How do I use them
SQL Server 2016 Execution Plan Analysis Liviu Ieran
Hugo Kornelis Now where does THAT estimate come from? The nuts and bolts of cardinality estimation.
The 5 Hidden Performance Gems
Database systems Lecture 6 – Indexes
Transact SQL Performance Tips
Ascending Key Problem in SQL Server Large Tables
Statistics for beginners – In-Memory OLTP
Query Processing CSD305 Advanced Databases.
Parameter Sniffing on SQL Server
Introduction to Execution Plans
T-SQL Basics: Coding for performance
Introduction to Execution Plans
Working with Very Large Tables Like a Pro in SQL Server 2017
Presentation transcript:

Maciej Pilecki | Project Botticelli Ltd.

SELECT Bio FROM Speakers WHERE FullName=‘Maciej Pilecki’;  Microsoft Certified Trainer since 2001  SQL Server MVP since Jan 2006  Specializing in SQL Server database development and administration  Delivering training and consulting services around the world  Frequent speaker at many international conferences and UG meetings

Agenda  Introduction to statistics  Statistics internals  Creating statistics  Maintaining statistics

How the Query Optimizer Works Source: SQL 2008 Books Online

How the Query Optimizer Works  SQL Server uses "cost-based" optimizer  Execution plan is chosen based on the ESTIMATED cost of execution  Cost estimation based on the number of rows processed (cardinality estimation)  Cardinality estimation based on ○ Number of rows in a table ○ Data distribution statistics  Optimizer estimates selectivity of a query

What are Statistics?  Statistics hold data distribution information about of values in a column or a set of columns  Statistics contain: Distribution for leading column Density information for column combinations  Every index has associated statistics

Statistics internals  Viewing statistics: sys.stats sys.stats_columns DBCC SHOW_STATISTICS

Creating statistics  Automatically: Depends on AUTO_CREATE_STATISTICS database option For every index For each non-indexed column used in the query predicate  Manually: CREATE STATISTICS sp_createstats

Maintaining statistics  Outdated stats can lead to suboptimal execution plans  Stats have to be refreshed

Maintaining statistics  Automatically, depending on: ○ AUTO_UPDATE_STATISTICS database setting ○ STATISTICS_NORECOMPUTE option of the index ○ NORECOMPUTE option of the statistics ○ sp_autostats ○ AUTO_UPDATE_STATISTICS_ASYNC database option  Manually: ○ UPDATE STATISTICS ○ sp_updatestats ○ Index rebuild

Auto-updates  Thresholds for auto-updates: For temp table with less than 6 rows – after every 6 updates For table with less than 500 rows - after 500 updates For larger table - after % of rows For table variables – NEVER Described in KB Updates tracked in rowmodctrs sysindexes

Best practices  Don't turn off: AUTO_CREATE_STATISTICS AUTO_UPDATE_STATISTICS  Rebuild your indexes from time to time Performs a full-scan update of statistics  Run sp_updatestats after any major update

Summary  Introduction to statistics  Statistics internals  Creating statistics  Maintaining statistics

Related Content  Statistics Used by the Query Optimizer in Microsoft SQL Server  Elisabeth Redei – Lies, Damn Lies and Statistics (in two parts): damned-lies-and-statistics-part-i.aspx  SQL Server Internals and Query Tuning class: Mainz, November