SlideShare a Scribd company logo
1 of 32
INDEX REORGANIZATION
AND REBUILDING FOR
SUCCESS
An end-to-end Enterprise re-indexing process
ABSTRACT
Dean will introduce a process and accompanying tools to make Index
reorganization/rebuilding successful. Applicable on small databases and multi-Tb
databases with over 20,000 tables (including examples of what can go horribly wrong
without the right preparation). Bonus: PowerShell monitoring script included.
AGENDA
• Indexing - What can go wrong?
• Process Overview
• Pre-requisites (initial setup/configuration)
• Pre-index preparation
• Running Index optimization
• Index progress monitoring (awesome PowerShell script)
WHAT COULD POSSIBLY GO WRONG?
WHAT COULD POSSIBLY GO
WRONG?
Lose your job BAD
• Disk out of space
• Tlog or Database files
• Tlog backup files
• Exponential Tlog growth
Temporarily pain
• Tlog or database growth initialization causing application timeout
CONSIDERATIONS
• Enterprise Edition
• Online Index rebuild
• Tlog auto-growth settings
• % or size
• Size planning
• Full backups during re-index
• Tlog will not truncate during a full backup even if log backups are being taken
• Big database (4 hr backup + recovery)  use differentials during re-index?
• TODO: Add log_reuse_wait_desc to Powershell monitoring tool when log used percent is >
warning threshold.
• Re-Index vs. Re-Organize
• MaxDOP?
• TempDb
PROCESS OVERVIEW
PROCESS OVERVIEW
INITIAL SYSTEM SETUP/CONFIGURATION
Pre-requisites to using the proposed (demo) process
OLA HALLENGREN’S INDEX
MAINTENANCE SCRIPT
• https://ola.hallengren.com/
• Optional, but recommended
• CommandLog table
OLA’S INSTALL SCRIPTS
• Demo uses a DBA AdminUtility
database (instead of master)
• @CreateJobs set to Yes
• @LogToTable set to Yes
SQL AGENT JOBS
• Ola’s scripts will add these jobs
• The IndexOptimize – USER_DATABASES job is the
one of interest for indexing
ADMINISTRATIVE DATABASE OR
TABLES
SP_WHOISACTIVE
• Adam Machanic’s sp_WhoIsActive script is a new and improved version of sp_who2
• http://sqlblog.com/blogs/adam_machanic/archive/tags/who+is+active/default.aspx
• Shows current connections, % progress of index re-organization, and much more
SCHEDULED TASK
SCHEDULED TASK - TRIGGER
• How often to run during indexing
SCHEDULED TASK - ACTION
• ExecutionPolicy Bypass
SCHEDULED TASK - RUN
PRE-INDEX PREPARATION
PRE-INDEX PREPARATION FOR VLDB
• Tlog backup schedule
• Shorten duration
• Full backup schedule
• Temporarily switch to differential backups
• Open monitoring tools or schedule the Sweet Powershell script
INDEX MAINTENANCE
INDEX MAINTENANCE
• Ola Hallengren Index Maintenance Solution (recommended)
• Queryable maintenance database (read: Sweet PowerShell monitoring)
• Post maintenance review (% fragmentation, re-org vs. rebuild, etc.)
• Maintenance Plans
PROGRESS MONITORING
INDEX MONITORING – OLD SCHOOL
• DMV – Disk Usage
• Windows Explorer – .trn backup file sizes
• Windows Explorer – tlog backup duration
• sp_who2
INDEX MONITORING – LIKE A BOSS
• Powershell Script
• sp_WhoIsActive (by Adam Mechanic)
• Queries
• Completed indexes
• Current index rebuild progress (%, rows remaining)
• Current index reorg progress (%)
• Disk space used (Database files and Tlog
• Tlog backup size and backup duration
• Windows Scheduler
• Email
TLOG ABOUT TO GROW
• Transactions are paused while TLOG file
is growing
• Truncation should prevent growth
depending on initial size
• Autogrowth settings…
DATA FILE ABOUT TO GROW
TLOG ACTIVITY
Re-org (~1 Gb/minute) Re-build (~200Kb/minute)
TLOG BACKUP DURATION
• Durations shown in the query don’t
include the –WithVerify time
• I usually use a 3X multiplier for
estimating actual tlog backup time
• Look at start time of next backup
INDIVIDUAL INDEX PROGRESS
Re-Org Re-Build
WARNING SIGNS
• VLDB data file about to grow
• TLOG file about to grow
• TLOG backup duration + Verify taking
longer than backup schedule schedule
• Log file not truncating (excessive
growth)
• Wait times on sp_WhoIsActive
• File sizes growing larger than available
disk space
DEAN WILLSON
• Director of Application Development, Aunt Millie’s Bakeries
• Long time member of NUFW
• Former President of fwPASS
• Twitter: @deanwillson
• Blogs: dean-o.blogspot.com, practicalhoshin.blogspot.com
• LinkedIn: http://linkedin.com/in/deanwillson

More Related Content

Similar to Index Reorganization and Rebuilding for Success

COUG_AAbate_Oracle_Database_12c_New_Features
COUG_AAbate_Oracle_Database_12c_New_FeaturesCOUG_AAbate_Oracle_Database_12c_New_Features
COUG_AAbate_Oracle_Database_12c_New_Features
Alfredo Abate
 

Similar to Index Reorganization and Rebuilding for Success (20)

Introducing the Apache Flink Kubernetes Operator
Introducing the Apache Flink Kubernetes OperatorIntroducing the Apache Flink Kubernetes Operator
Introducing the Apache Flink Kubernetes Operator
 
An AMIS Overview of Oracle database 12c (12.1)
An AMIS Overview of Oracle database 12c (12.1)An AMIS Overview of Oracle database 12c (12.1)
An AMIS Overview of Oracle database 12c (12.1)
 
An AMIS overview of database 12c
An AMIS overview of database 12cAn AMIS overview of database 12c
An AMIS overview of database 12c
 
Oracle EBS Production Support - Recommendations
Oracle EBS Production Support - RecommendationsOracle EBS Production Support - Recommendations
Oracle EBS Production Support - Recommendations
 
Oracle migrations and upgrades
Oracle migrations and upgradesOracle migrations and upgrades
Oracle migrations and upgrades
 
Database Fundamental Concepts- Series 1 - Performance Analysis
Database Fundamental Concepts- Series 1 - Performance AnalysisDatabase Fundamental Concepts- Series 1 - Performance Analysis
Database Fundamental Concepts- Series 1 - Performance Analysis
 
HBaseCon 2013: Near Real Time Indexing for eBay Search
HBaseCon 2013: Near Real Time Indexing for eBay SearchHBaseCon 2013: Near Real Time Indexing for eBay Search
HBaseCon 2013: Near Real Time Indexing for eBay Search
 
python_development.pptx
python_development.pptxpython_development.pptx
python_development.pptx
 
Sql server tips from the field
Sql server tips from the fieldSql server tips from the field
Sql server tips from the field
 
Time Travelling With DB2 10 For zOS
Time Travelling With DB2 10 For zOSTime Travelling With DB2 10 For zOS
Time Travelling With DB2 10 For zOS
 
AUSPC 2013 - Business Continuity Management in SharePoint
AUSPC 2013 - Business Continuity Management in SharePointAUSPC 2013 - Business Continuity Management in SharePoint
AUSPC 2013 - Business Continuity Management in SharePoint
 
Evolutionary database design
Evolutionary database designEvolutionary database design
Evolutionary database design
 
Datastage Introduction To Data Warehousing
Datastage Introduction To Data WarehousingDatastage Introduction To Data Warehousing
Datastage Introduction To Data Warehousing
 
Tarabica 2019 (Belgrade, Serbia) - SQL Server performance troubleshooting
Tarabica 2019 (Belgrade, Serbia) - SQL Server performance troubleshootingTarabica 2019 (Belgrade, Serbia) - SQL Server performance troubleshooting
Tarabica 2019 (Belgrade, Serbia) - SQL Server performance troubleshooting
 
Problems with PostgreSQL on Multi-core Systems with MultiTerabyte Data
Problems with PostgreSQL on Multi-core Systems with MultiTerabyte DataProblems with PostgreSQL on Multi-core Systems with MultiTerabyte Data
Problems with PostgreSQL on Multi-core Systems with MultiTerabyte Data
 
COUG_AAbate_Oracle_Database_12c_New_Features
COUG_AAbate_Oracle_Database_12c_New_FeaturesCOUG_AAbate_Oracle_Database_12c_New_Features
COUG_AAbate_Oracle_Database_12c_New_Features
 
Remote DBA Experts SQL Server 2008 New Features
Remote DBA Experts SQL Server 2008 New FeaturesRemote DBA Experts SQL Server 2008 New Features
Remote DBA Experts SQL Server 2008 New Features
 
Oracle 10g Introduction 1
Oracle 10g Introduction 1Oracle 10g Introduction 1
Oracle 10g Introduction 1
 
Presto: Fast SQL on Everything
Presto: Fast SQL on EverythingPresto: Fast SQL on Everything
Presto: Fast SQL on Everything
 
Extreme Makeover OnBase Edition
Extreme Makeover OnBase EditionExtreme Makeover OnBase Edition
Extreme Makeover OnBase Edition
 

More from Dean Willson

More from Dean Willson (10)

Visual Studio 2012 Productivity Tools
Visual Studio 2012 Productivity ToolsVisual Studio 2012 Productivity Tools
Visual Studio 2012 Productivity Tools
 
Intro to Powershell
Intro to PowershellIntro to Powershell
Intro to Powershell
 
Continuous improvement in a professional organization
Continuous improvement in a professional organizationContinuous improvement in a professional organization
Continuous improvement in a professional organization
 
Database Source Control
Database Source ControlDatabase Source Control
Database Source Control
 
Career Transitions - Ball State University, Six Sigma Speakers Series
Career Transitions - Ball State University, Six Sigma Speakers SeriesCareer Transitions - Ball State University, Six Sigma Speakers Series
Career Transitions - Ball State University, Six Sigma Speakers Series
 
Introduction to SQL Server 2008 Management Data Warehouse (MDW)
Introduction to SQL Server 2008 Management Data Warehouse (MDW)Introduction to SQL Server 2008 Management Data Warehouse (MDW)
Introduction to SQL Server 2008 Management Data Warehouse (MDW)
 
Implementing ASP.NET Role Based Security
Implementing ASP.NET Role Based SecurityImplementing ASP.NET Role Based Security
Implementing ASP.NET Role Based Security
 
Introduction to SSRS Report Builder
Introduction to SSRS Report BuilderIntroduction to SSRS Report Builder
Introduction to SSRS Report Builder
 
Data Mining with SQL Server 2005
Data Mining with SQL Server 2005Data Mining with SQL Server 2005
Data Mining with SQL Server 2005
 
Designing For Occasionally Connected Apps Slideshare
Designing For Occasionally Connected Apps SlideshareDesigning For Occasionally Connected Apps Slideshare
Designing For Occasionally Connected Apps Slideshare
 

Recently uploaded

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Recently uploaded (20)

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 

Index Reorganization and Rebuilding for Success

  • 1. INDEX REORGANIZATION AND REBUILDING FOR SUCCESS An end-to-end Enterprise re-indexing process
  • 2. ABSTRACT Dean will introduce a process and accompanying tools to make Index reorganization/rebuilding successful. Applicable on small databases and multi-Tb databases with over 20,000 tables (including examples of what can go horribly wrong without the right preparation). Bonus: PowerShell monitoring script included.
  • 3. AGENDA • Indexing - What can go wrong? • Process Overview • Pre-requisites (initial setup/configuration) • Pre-index preparation • Running Index optimization • Index progress monitoring (awesome PowerShell script)
  • 5. WHAT COULD POSSIBLY GO WRONG? Lose your job BAD • Disk out of space • Tlog or Database files • Tlog backup files • Exponential Tlog growth Temporarily pain • Tlog or database growth initialization causing application timeout
  • 6. CONSIDERATIONS • Enterprise Edition • Online Index rebuild • Tlog auto-growth settings • % or size • Size planning • Full backups during re-index • Tlog will not truncate during a full backup even if log backups are being taken • Big database (4 hr backup + recovery)  use differentials during re-index? • TODO: Add log_reuse_wait_desc to Powershell monitoring tool when log used percent is > warning threshold. • Re-Index vs. Re-Organize • MaxDOP? • TempDb
  • 9. INITIAL SYSTEM SETUP/CONFIGURATION Pre-requisites to using the proposed (demo) process
  • 10. OLA HALLENGREN’S INDEX MAINTENANCE SCRIPT • https://ola.hallengren.com/ • Optional, but recommended • CommandLog table
  • 11. OLA’S INSTALL SCRIPTS • Demo uses a DBA AdminUtility database (instead of master) • @CreateJobs set to Yes • @LogToTable set to Yes
  • 12. SQL AGENT JOBS • Ola’s scripts will add these jobs • The IndexOptimize – USER_DATABASES job is the one of interest for indexing
  • 14. SP_WHOISACTIVE • Adam Machanic’s sp_WhoIsActive script is a new and improved version of sp_who2 • http://sqlblog.com/blogs/adam_machanic/archive/tags/who+is+active/default.aspx • Shows current connections, % progress of index re-organization, and much more
  • 16. SCHEDULED TASK - TRIGGER • How often to run during indexing
  • 17. SCHEDULED TASK - ACTION • ExecutionPolicy Bypass
  • 20. PRE-INDEX PREPARATION FOR VLDB • Tlog backup schedule • Shorten duration • Full backup schedule • Temporarily switch to differential backups • Open monitoring tools or schedule the Sweet Powershell script
  • 22. INDEX MAINTENANCE • Ola Hallengren Index Maintenance Solution (recommended) • Queryable maintenance database (read: Sweet PowerShell monitoring) • Post maintenance review (% fragmentation, re-org vs. rebuild, etc.) • Maintenance Plans
  • 24. INDEX MONITORING – OLD SCHOOL • DMV – Disk Usage • Windows Explorer – .trn backup file sizes • Windows Explorer – tlog backup duration • sp_who2
  • 25. INDEX MONITORING – LIKE A BOSS • Powershell Script • sp_WhoIsActive (by Adam Mechanic) • Queries • Completed indexes • Current index rebuild progress (%, rows remaining) • Current index reorg progress (%) • Disk space used (Database files and Tlog • Tlog backup size and backup duration • Windows Scheduler • Email
  • 26. TLOG ABOUT TO GROW • Transactions are paused while TLOG file is growing • Truncation should prevent growth depending on initial size • Autogrowth settings…
  • 27. DATA FILE ABOUT TO GROW
  • 28. TLOG ACTIVITY Re-org (~1 Gb/minute) Re-build (~200Kb/minute)
  • 29. TLOG BACKUP DURATION • Durations shown in the query don’t include the –WithVerify time • I usually use a 3X multiplier for estimating actual tlog backup time • Look at start time of next backup
  • 31. WARNING SIGNS • VLDB data file about to grow • TLOG file about to grow • TLOG backup duration + Verify taking longer than backup schedule schedule • Log file not truncating (excessive growth) • Wait times on sp_WhoIsActive • File sizes growing larger than available disk space
  • 32. DEAN WILLSON • Director of Application Development, Aunt Millie’s Bakeries • Long time member of NUFW • Former President of fwPASS • Twitter: @deanwillson • Blogs: dean-o.blogspot.com, practicalhoshin.blogspot.com • LinkedIn: http://linkedin.com/in/deanwillson