Finding more space for your tight environment

Slides:



Advertisements
Similar presentations
Module 3: Creating and Tuning Indexes. Planning Indexes Creating Indexes Optimizing Indexes.
Advertisements

SQL Server Storage Engine.  Software architect at Red Gate Software  Responsible for SQL tools: ◦ SQL Compare, SQL Data Compare, SQL Packager ◦ SQL.
Big Data Working with Terabytes in SQL Server Andrew Novick
SQL Server Compression Estimation Presented by Warwick Rudd –
SQL Server 2005 features for VLDBs. SQL Server 2005 features for VLDBs aka (it’s fixed in the next release)
Project Management Database and SQL Server Katmai New Features Qingsong Yao
Tables Lesson 6. Skills Matrix Tables Tables store data. Tables are relational –They store data organized as row and columns. –Data can be retrieved.
Working with SQL Server Database Objects
Database Optimization & Maintenance Tim Richard ECM Training Conference#dbwestECM Agenda SQL Configuration OnBase DB Planning Backups Integrity.
Backup, Integrity Check and Index and Statistics Maintenance
André Kamman Friday November 20 SQLBITS IV. About Me  André Kamman  > 20 years in IT  Main focus on complex SQL Server environments (or a whole.
Lecture 6 Indexing Part 2 Column Stores. Indexes Recap Heap FileBitmapHash FileB+Tree InsertO(1) O( log B n ) DeleteO(P)O(1) O( log B n ) Range Scan O(P)--
Exam QUESTION CertKiller.com has hired you as a database administrator for their network. Your duties include administering the SQL Server 2008.
Objectives Learn what a file system does
Chapter Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.
Sofia, Bulgaria | 9-10 October SQL Server 2005 High Availability for developers Vladimir Tchalkov Crossroad Ltd. Vladimir Tchalkov Crossroad Ltd.
Extents, segments and blocks in detail. Database structure Database Table spaces Segment Extent Oracle block O/S block Data file logical physical.
TEMPDB Capacity Planning. Indexing Advantages – Increases performance – SQL server do not have to search all the rows. – Performance, Concurrency, Required.
Architecture Rajesh. Components of Database Engine.
SQL Server Indexes Indexes. Overview Indexes are used to help speed search results in a database. A careful use of indexes can greatly improve search.
Partitioning Design For Performance and Maintainability Martin Cairns
Module 16: Performing Ongoing Database Maintenance
Indexes / Session 2/ 1 of 36 Session 2 Module 3: Types of Indexes Module 4: Maintaining Indexes.
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.
SQLintersection Putting the "Squeeze" on Large Tables Improve Performance and Save Space with Data Compression Justin Randall Tuesday,
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.
MISSION CRITICAL COMPUTING Siebel Database Considerations.
Maintenance Practices. Goal  Automate the necessary DBA chores to put organizations on the path of having healthier, consistent and more trustworthy.
Retele de senzori Curs 2 - 1st edition UNIVERSITATEA „ TRANSILVANIA ” DIN BRAŞOV FACULTATEA DE INGINERIE ELECTRICĂ ŞI ŞTIINŢA CALCULATOARELOR.
October 15-18, 2013 Charlotte, NC Accelerating Database Performance Using Compression Joseph D’Antoni, Solutions Architect Anexinet.
SQL SERVER MAINTENANCE PLANS Kat
SQL Server Statistics DEMO SQL Server Statistics SREENI JULAKANTI,MCTS.MCITP,MCP. SQL SERVER Database Administration.
Secure SQL Database with TDE Thomas Chan SQL Saturday Raleigh.
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.
Indexing strategies and good physical designs for performance tuning Kenneth Ureña /SpanishPASSVC.
Storage and File Organization
Chris Index Feng Shui Chris
Standard/Express edition
Compression and Storage Optimization IDS xC4 Kevin Cherkauer
Inside transaction logging
Module 11: File Structure
Indexing Structures for Files and Physical Database Design
CS 540 Database Management Systems
Antonio Abalos Castillo
Resumable Online Index Rebuild (ROIR) in SQL 2017 & SQL DB
Module 4: Creating and Tuning Indexes
Introduction to SQL Server Management for the Non-DBA
Database Administration for the Non-DBA
Dynamics AX Performance
Instant Add Columns in MySQL
DATABASE MANAGEMENT SYSTEM
Module 11: Data Storage Structure
Squeeze Into Some Free Gains
Statistics: What are they and How do I use them
Inside transaction logging
Table Partitioning Intro and make that a sliding window too!
Microsoft SQL Server 2014 for Oracle DBAs Module 7
In Memory OLTP Not Just for OLTP.
Adding Lightness Better Performance through Compression
Chapter 13: Data Storage Structures
Table Partitioning Intro and make that a sliding window too!
Four Rules For Columnstore Query Performance
Secure/Encrypt SQL Server Database With TDE
Squeeze Into Some Free Gains
Table Partitioning Intro and make that a sliding window too!
Diving into Query Execution Plans
Understanding Core Database Concepts
Chapter 13: Data Storage Structures
CS222/CS122C: Principles of Data Management UCI, Fall 2018 Notes #03 Row/Column Stores, Heap Files, Buffer Manager, Catalogs Instructor: Chen Li.
Presentation transcript:

Finding more space for your tight environment Thomas Chan SQL Saturday 638 - Philadelphia

Thanks Vendors

Who am I ? I work for Virginia state as SQL DBA I have 18+ year in IT and use SQL since 7 I love computer, database and Sid Meier's Civilization

Agenda Demo How can I get more disk space? Our solution, like downsize your house compress data shrink file defrag indexes and update statistics. Demo

How can we get more disk space? Buy more disk space, means $$$ Purge/delete old or unnecessary data Our solution (downsize your house) Compress data – buy a smaller house Shrink data file – move to smaller house as fast as possible Defrag index and update statistics – organize your stuff Share free space among servers using for example iSCSI protocol (file in a server is a hard disk in the target server)

Compression Definition of data compression: reduction of space used to store a piece of information. Enterprise only, except SQL 2016 SP1 Transparent to user or developer, no coding Compressed pages remain compressed in memory/buffer pool Type of page compression in SQL Server Row Page Other (Unicode, column-store) Backup - since 2008 It may improve performance of database

Compression – B-tree index Row only Row and Page

Row Compression Compress data at row level Smart way to store data Use variable length for numeric type Use variable length for fixed string format Null and 0 require 0 bytes Reduce metadata overhead associated with the records https://msdn.microsoft.com/en-us/library/cc280576.aspx

Page Compression Compress leaf pages at page level The compression consist 3 phase: Row compression Prefix compression – compress common patterns Dictionary compression – compress common patterns again (data and prefix) https://msdn.microsoft.com/en-us/library/cc280464.aspx

Page Compression - Prefix Compress common patterns in the beginning of each columns

Page Compression - Dictionary Compress common patterns across all columns after prefix compression

Page vs Row Table Savings ROW % Savings PAGE % S U Decision Notes T1 80% 90% 3.80% 57.27% ROW Low S, very high U. ROW savings close to PAGE T2 15% 89% 92.46% 0% PAGE Very high S T3 30% 81% 27.14% 4.17% Low S T4 38% 83% 89.16% 10.54% High U T5 21% 87% 0.00% Append ONLY table T6 28% 87.54% High S, low U T7 29% 88% 0.50% 99% appends T8 11.44% 0.06% 85% appends T9 84% 92% 0.02% ROW savings ~= PAGE T10 100.00% Read ONLY table Data Compression: Strategy, Capacity Planning and Best Practices https://technet.microsoft.com/en-us/library/dd894051(v=sql.100).aspx

Compression Detail Space to be save can estimate by each type of compression and table or index Objects can be compressed: heap, index and indexed view, essentially partition Partitioned data require less disk space to compress the same data than data with unique partition New page allocated in a heap by DML will not use PAGE compression until it is rebuilt Change compression type of heap will rebuild ALL non-clustered indexes The non-leaf pages can only be compressed to row compression while leaf page can to both type: row and page https://msdn.microsoft.com/en-us/library/cc280449.aspx

Compression Tips Start from smaller partitions to bigger one (require workspace) Start from heap (when compress heap, non-clustered are compress too) Start from clustered index Use sys.dm_db_index_operational_stats High scan  page compression High update  row compression Use sys.sp_estimate_data_compression_savings to estimate saving Durante the compression do not forget backup transaction log backup

Compression Syntax ALTER TABLE Tab1 REBUILD WITH (MAXDOP=1, COMPRESSION=NONE | ROW | PAGE) ALTER INDEX IX01 ON TABLE Tab1 REBUILD WITH (MAXDOP=1, COMPRESSION=NONE | ROW | PAGE) ALTER TABLE Tab1 REBUILD WITH (PARTITION=1, MAXDOP=1, COMPRESSION=NONE | ROW | PAGE) EXEC sp_estimate_data_compression_savings ‘Sch1’, ‘Tab1', ‘IX01', NULL | <Partit Num>, ‘NONE’ | ‘ROW’ | ‘PAGE’ Compression Partition Shrink Data File Defrag Index Update statistics

Shrink Data File Why? Because we need free space for OS and the space freed by data compression remain reserved to database Shrink vs Defrag Shrink = Downsize = release as fast is possible the free space to windows Defrag/reorganize = Organize USE db1 GO DBCC SHRINK (‘db1’, 1024);

Index Defragmentation There are two defragmentation method: Reorganize: defrag leaf page only, recommended average fragmentation between 5% to 30% Rebuild: defrag leaf and root of index, recommended average fragmentation over 30% Online defrag is enterprise only

Update Statistics SQL query optimizer uses statistic to generate high quality query execution plan. Consider update statistic after any major change of data distribution like table truncation, bulk insert or any large update. To view the distribution of statistics use DBCC SHOW_STATISTICS (‘sch.table’, PK_table) WITH HISTOGRAM; To update statistic uses UPDATE STATISTICS sch.table; UPDATE STATISTICS sch.table PK_table; UPDATE STATISTICS sch.table(column) WITH SAMPLE 50 PERCENT; EXEC sys. sp_updatestats;

Demo Run query to estimate space saving, update and scan percentage with compression command Run compression command Backup with and without compression Shrink data file Defrag indexes Update Statistics (show statistic distribution)