Rui Ribeiro MCITP 2010/10/19 Index optimization … …on low peak periods V ENCONTRO DA COMUNIDADE SQLPORT.

Slides:



Advertisements
Similar presentations
Big Data Working with Terabytes in SQL Server Andrew Novick
Advertisements

“What do you want me to do now?”
Common Mistakes Developers Make By Bryan Oliver SQL Server Mentor at SolidQ.
Challenge for all the Seniors (DBAs) QuestionAreaYou (Today) You (6 Months) You (1 Year) 1Design Tables 2Write Queries 3Deploy Changes 4Tune Queries 5Monitor.
Module 6 Implementing Table Structures in SQL Server ®2008 R2.
Calendar Browser is a groupware used for booking all kinds of resources within an organization. Calendar Browser is installed on a file server and in a.
Deadlock Avoidance CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han.
Software Performance Engineering - SPE HW - Answers Steve Chenoweth CSSE 375, Rose-Hulman Tues, Oct 23, 2007.
Software Performance Engineering Steve Chenoweth CSSE 375, Rose-Hulman Tues, Oct 23, 2007.
Saturday May 02 PST 4 PM. Saturday May 02 PST 10:00 PM.
Denny Cherry twitter.com/mrdenny.
Introduction to Data Analysis *Training Session*
Desktop Security: Worms and Viruses Brian Arkills, C&C NDC-Sysmgt.
Database Systems Marcus Kaiser School of Computing Science Newcastle University.
PostgreSQL and relational databases As well as assignment 4…
New ways of learning week Sign up at: Monday 25 th November Tuesday 26 th November Wednesday 27 th November Thursday.
Sofia, Bulgaria | 9-10 October Concurrency Management – ADO.NET 2.0 Presented By: Sahil Malik Presented By: Sahil Malik
PHP meets MySQL.
Physical Database Design & Performance. Optimizing for Query Performance For DBs with high retrieval traffic as compared to maintenance traffic, optimizing.
CODD’s 12 RULES OF RELATIONAL DATABASE
INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014.
PostgreSQL and relational databases As well as assignment 4…
SQL Server 7.0 Maintaining Referential Integrity.
SQL pepper. Why SQL File I/O is a great deal of code Optimal file organization and indexing is critical and a great deal of code and theory implementation.
11-1 Improve response time of interactive programs. Improve batch throughput. To ensure scalability of applications load vs. performance. Reduce system.
Page 1 SQL Server Myths XV ENCONTRO DA COMUNIDADE SQLPORT Rui Ribeiro MCITP 2011/08/16.
Table Indexing for the.NET Developer Denny Cherry twitter.com/mrdenny.
2. GATHERING REQUIREMENTS Object-Oriented Analysis and Design NTPCUG.
Participate in a Team to Achieve Organizational Goal
Session 4: PREPARE FOR TESTS Year 7 Life Skills Student Wall Planner and Study Guide.
M1G Introduction to Database Development 2. Creating a Database.
Hibernate Persistence. What is Persistence Persist data to database or other storage.  In OO world, persistence means persist object to external storage.
COMP 208/214/215/216 – Lecture 8 Demonstrations and Portfolios.
Views Lesson 7.
1 CS Tutorial 5 Frid. Oct 23, 2009 Design Document Tutorial.
Incremental Index Maintenance A Solution “That Just Works” AL NOEL PRINCIPAL CONSULTANT, MICROSOFT
Denny Cherry twitter.com/mrdenny.
Module 3 Designing and Implementing Tables. Module Overview Designing Tables Working with Schemas Creating and Altering Tables.
IUIE Admissions Reports Digging Deeper University Graduate School.
The Relational Model1 Transaction Processing Units of Work.
Grade Book Database Presentation Jeanne Winstead CINS 137.
SQL/Lesson 7/Slide 1 of 32 Implementing Indexes Objectives In this lesson, you will learn to: * Create a clustered index * Create a nonclustered index.
SQL SERVER DAYS 2011 Table Indexing for the.NET Developer Denny Cherry twitter.com/mrdenny.
Chapter 5 : Integrity And Security  Domain Constraints  Referential Integrity  Security  Triggers  Authorization  Authorization in SQL  Views 
Learningcomputer.com SQL Server 2008 –Views, Functions and Stored Procedures.
Student Centered ODS ETL Processing. Insert Search for rows not previously in the database within a snapshot type for a specific subject and year Search.
Creating Indexes on Tables An index provides quick access to data in a table, based on the values in specified columns. A table can have more than one.
Session id: Darrell Hilliard Senior Delivery Manager Oracle University Oracle Corporation.
IS6146 Databases for Management Information Systems Lecture 3: SQL III – The DDL Rob Gleasure robgleasure.com.
Computer/Human Interaction Spring 2013 Northeastern University1 Name of Interface Tagline if you have one (80 chars max, including spaces) Team member.
Using Workflow With Dataforms Tim Borntreger, Director of Client Services.
Week 6 - Friday.  What did we talk about last time?  Loop examples.
Table Structures and Indexing. The concept of indexing If you were asked to search for the name “Adam Wilbert” in a phonebook, you would go directly to.
SQL Server Statistics DEMO SQL Server Statistics SREENI JULAKANTI,MCTS.MCITP,MCP. SQL SERVER Database Administration.
Does the Optimistic Concurrency resolve your blocking problems Margarita Naumova, SQL Master Academy.
SQL Server Statistics DEMO SQL Server Statistics SREENI JULAKANTI,MCTS.MCITP SQL SERVER Database Administration.
In this session, you will learn to: Create and manage views Implement a full-text search Implement batches Objectives.
Making more hours in the day Managing your time at university This workshop was originally produced at the.
Locks, Blocks & Isolation Oh My!. About Me Keith Tate Data Professional for over 14 Years MCITP in both DBA and Dev tracks
Jeremy Kingry, eBECS | ADVANCED SQL SERVER FOR ADMINS AND ANALYSTS.
In this session, you will learn to: Manage databases Manage tables Objectives.
Decision Analysis Fall Term 2015 Marymount University School of Business Administration Professor Suydam Week 10 Access Basics – Tutorial B; Introduction.
SQL IMPLEMENTATION & ADMINISTRATION Indexing & Views.
Controlling User Access
SQL Implementation & Administration
Module 5: Implementing Data Integrity by Using Constraints
Lecturer: Mukhtar Mohamed Ali “Hakaale”
Simple Partitioning Building a simple partitioning solution with SQL Server Stephen Fulcher.
JULIE McLAIN-HARPER LINKEDIN: JM HARPER
Four Rules For Columnstore Query Performance
Presentation transcript:

Rui Ribeiro MCITP 2010/10/19 Index optimization … …on low peak periods V ENCONTRO DA COMUNIDADE SQLPORT

Topics to be Adressed: –Problem Description; –Implementation Overview: - Pessimistic scenario; -Optimistic scenario. -Schedule Index Maintenance; -Demo

1) Problem Description

1)Problem Description __________________________________________ OLTP SQL Server environment Some DBs > 2 TB Some tables > 500 MB Public Access –[20 hours in a row] x 7 days a week. Daily Processing Batchs

Weekly activity

As always, and as everyone else, I was running short in time, and I had to get it all working A.S.A.P.. In the search of the “wheel” that someone had already invented and which wasn´t a complete answer to my problem…

... I´ve found several Index Optimization solutions … The base of the process I am about to describe here it’s available on:

I stated that it wasn´t a complete answer to my problem because it was impossible to: -Exclude indexes from being optimized on a specific week day; -Perform index maintenance for a short period, and then again start on another short period, starting from the point where it ended before; -It didn´t had a way to help DBA to decide which indexes should(‘nt) be maintained during weekday/weekend

All I needed was a solution to support Index maintenance like this: 1) Imagine I want to start a Index Maintenance plan (IMP) IMPSTEPS CHECKEDACTIONS Has Performs Id Info StartDate EndDate Id Id_CHECKED Id_IMP Id_STEPS StartDate EndDate DBNAME TableName IndexName CurrentFragmentationLevel CurrentPageCountl StartDate EndDate Checked ActiontDate StartDate EndDate Command Comment Result IndexChecked 1N N ) IT will have as many Steps as those required to be performed accordingly time spend in each Job execution 3) N Indexes will be checked 4) In each Index Check, if required, a SQL statement will be used to handle each different Action

- Possibility to configure the maintenance of indexes of a particular database, to be performed automatically or manually - Ability to manage the maintenance of the indexes, on a daily basis; - Ability to take advantage of all the periods of low activity for the maintenance of such indexes. On the final solution reached, I highlight the following characteristics:

Implementation Overview - I am going to consider two scenarios in terms of the implementation of this Index Maintenance, namely: Pessimistic Optimistic

Implementation Overview : - Pessimistic scenario You are just the DBA and you don´t know nothing about the business behind the environment you are responsible for. You can also say that you don´t receive any help from the person which is supposed to know !...

Implementation Overview : - Optimistic scenario You understand the business behind the environment you are responsible for. You have all the help you need from the owner of the business.

Pessimistic scenario Collect information and configure/tune Index Maintenance Exclusion –At least once per month you have to (should!) collect information about each table regarding number of rows and data size on each one. –With the previous information, it is possible, using Pareto’s Principle (80-20 rule) to choose 20% most significant tables, that are going to be excluded from regular Index Maintenance, on regular days. Making those 20% only available to maintenance on Saturdays.

Pessimistic scenario Notes: –Why should we exclude the 20% most significant tables ? You can be sure that, in the least, the overhead caused by the smallest maintenance over the index of those 20% most significant tables will/could be significant. And the more complex the environment is, the probability of having locks, deadlocks, and related problems, increases ! So the point is: Why not just avoid any problem generated by this issue, during week days (critical ones!) ?

Optimistic scenario Manually configure Index Defrag Exclusion –Lets take a look on the table which is going to be used: - … to configure when is possible to optimize a specific index; - … to exclude a specific table or database from the optimization process. –If there isn’t any reference to a specific table/database in this table, that means that there isn’t any exclusion at all on that object !!!

Optimistic scenario Manually configure Index Defrag Exclusion Create Table dbo.DBA_indexDefragExclusion ( databaseID int Not Null, databaseName nvarchar(128) Not Null, objectID int Not Null, objectName nvarchar(128) Not Null, indexID int Not Null, indexName nvarchar(128) Not Null, exclusionMask int Not Null /* 1=Sunday, 2=Monday, 4=Tuesday, 8=Wednesday, 16=Thursday, 32=Friday, 64=Saturday Take a SUM of the values for the days that you want excluded. So if you want an index to only be defragged on weekends, you would add up Monday through Friday ( ) and use a value of 62 for the exclusionMask column. */ Constraint PK_indexDefragExclusion_v40 Primary Key Clustered (databaseID, objectID, indexID) );

Optimistic scenario Manually configure Index Defrag Exclusion At this point there are 3 possible actions: –Exclude all indexes from a specific database; –Configure some tables to be optimized whenever is suitable to business; –You don´t need /want to exclude anything !

Optimistic scenario: Manually configure Index Defrag Exclusion Action: Exclude all indexes from a specific database; USE DBNAME_Of_DB_2_Exclude go insert [DBA].dbo.DBA_indexDefragExclusion selectdb_id() as 'databaseID', db_name(db_id()) as 'databaseName', a.id as 'objectID', a.name as 'objectName', b.index_id as 'indexID', b.name as 'indexName', 127 as 'exclusionMask' from sys.sysobjects a join sys.indexes b on b.object_id = a.id and b.type > 0 where a.xtype like 'U'

Optimistic scenario: Manually configure Index Defrag Exclusion Action: Configure some tables to be optimized whenever is suitable to business; USE DBNAME_Of_DB_Selected go -- Only to be "worked" on weekend ! insert [DBA].dbo.DBA_indexDefragExclusion selectdb_id() as 'databaseID', db_name(db_id()) as 'databaseName', a.id as 'objectID', a.name as 'objectName', b.index_id as 'indexID', b.name as 'indexName', 62 as 'exclusionMask' from sys.sysobjects a join sys.indexes b on b.object_id = a.id and b.type > 0 where a.xtype like 'U' and a.name in ('Table1','Table2','TableA','TableZ')

Optimistic scenario: Manually configure Index Defrag Exclusion Action: You don´t need /want to exclude anything ! Great !!!

Schedule Index Maintenance After having configured which table should be ex/included on regular Index Maintenance in an automatic way (or after a certain manual tuning), we should have on table DBA_indexDefragExclusion all information required to make sure that no action is going to be performed over any Index in all critical tables, except in weekends (or whenever we wish !).

Schedule Index Maintenance: Schedules 1)Regular days (Monday to Friday) In my scenario, I had a non peak period between 20:00 and 22:00. Just to be sure that the Index Maintenance operation was not going to be extended too much from the limit time, I have used a time limit of 60 minutes. This way, if the Index Maintenance operation started a new index Maintenance on the 59 minute, I would have another 60 minutes of the non peak period … So, the job would ran on the regular days (from Monday to Friday), from 20:00 to 22:00.

Schedule Index Maintenance: Code 1)Regular days (Monday to Friday) EXECUTE = = = = = = = = = = min x 60 Secs

Schedule Index Maintenance: Schedules 2)Weekend (Saturday) Once again in my scenario, I have considered a low peak period on Saturday from 06:00 to 18:00, leaving time for the Systems Team to update system security patches or something else that could be required. So, the job would ran only during Saturday, from 06:00 to 18:00. Note: Regarding schedules, the main idea is that you can/should grab each non peak period and use it to perform this action of Index Optimization

Schedule Index Maintenance: Code 2)Weekend (Saturday) EXECUTE = = = = = = = = = = -- 10h x 60 min x 60 Secs = = 10h – Give 2 extra hours if Index Maintenance takes too long, considering that we are dealing with Indexes related with heavy/critical tables.

Last minute... More details... Questions... Other... And that’s all !