Bulk Load and Minimal Logging

Slides:



Advertisements
Similar presentations
Filegroup “Stage A” Filegroup “Stage A” Filegroup “A” Partition 1,2 Filegroup “B” Partition 3,4 Filegroup “C” Partition 5,6 Filegroup “D” Partition.
Advertisements

Module 8 Importing and Exporting Data. Module Overview Transferring Data To/From SQL Server Importing & Exporting Table Data Inserting Data in Bulk.
Moving Data Lesson 23. Skills Matrix Moving Data When populating tables by inserting data, you will discover that data can come from various sources.
Transaction Simon Cho. Who am I? Simon Cho Blog : Simonsql.com All Presentation and script will be on My.
SQL Server 2005 features for VLDBs. SQL Server 2005 features for VLDBs aka (it’s fixed in the next release)
CPSC-608 Database Systems Fall 2011 Instructor: Jianer Chen Office: HRBB 315C Phone: Notes #6.
Architecting a Large-Scale Data Warehouse with SQL Server 2005 Mark Morton Senior Technical Consultant IT Training Solutions DAT313.
1 Chapter Overview Transferring and Transforming Data Introducing Microsoft Data Transformation Services (DTS) Transferring and Transforming Data with.
DBI308. What are SQL Server Fast Track Reference Configurations General Fast Track Recommendations Reference Configurations and Best Practices FT 3.0.
SQL Server 2005 SP2 Israeli SQL Server User Group March 2005 Ami Levin
Database Technical Session By: Prof. Adarsh Patel.
Sofia, Bulgaria | 9-10 October SQL Server 2005 High Availability for developers Vladimir Tchalkov Crossroad Ltd. Vladimir Tchalkov Crossroad Ltd.
Physical Database Design & Performance. Optimizing for Query Performance For DBs with high retrieval traffic as compared to maintenance traffic, optimizing.
Architecture Rajesh. Components of Database Engine.
Databases and Statistical Databases Session 4 Mark Viney Australian Bureau of Statistics 5 June 2007.
1099 Why Use InterBase? Bill Todd The Database Group, Inc.
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.
1 Chapter 14 DML Tuning. 2 DML Performance Fundamentals DML Performance is affected by: – Efficiency of WHERE clause – Amount of index maintenance – Referential.
Module 11 Creating Highly Concurrent SQL Server® 2008 R2 Applications.
Indexes / Session 2/ 1 of 36 Session 2 Module 3: Types of Indexes Module 4: Maintaining Indexes.
Praveen Srivatsa Director| AstrhaSoft Consulting blogs.asthrasoft.com/praveens |
SQLintersection Putting the "Squeeze" on Large Tables Improve Performance and Save Space with Data Compression Justin Randall Tuesday,
Session 1 Module 1: Introduction to Data Integrity
Module 11: Managing Transactions and Locks
1 Indexes ► Sort data logically to improve the speed of searching and sorting operations. ► Provide rapid retrieval of specified rows from the table without.
Best Practices in Loading Large Datasets Asanka Padmakumara (BSc,MCTS) SQL Server Sri Lanka User Group Meeting Oct 2013.
5 Trends in the Data Warehousing Space Source: TDWI Report – Next Generation DW.
SQL Server 2005 – Table Partitioning Chad Gronbach Microsoft.
October 15-18, 2013 Charlotte, NC Accelerating Database Performance Using Compression Joseph D’Antoni, Solutions Architect Anexinet.
6/13/2015 Visit the Sponsor tables to enter their end of day raffles. Turn in your completed Event Evaluation form at the end of the day in the Registration.
# CCNZ What is going on here???
11 Copyright © 2004, Oracle. All rights reserved. Performing a Migration Using Oracle Migration Workbench (Part II)
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.
A Lap Around Columstore Martin Catherall SQL Saturday #464, Melbourne 20 th February 2016.
Data Integrity & Indexes / Session 1/ 1 of 37 Session 1 Module 1: Introduction to Data Integrity Module 2: Introduction to Indexes.
Introducing Hekaton The next step in SQL Server OLTP performance Mladen Prajdić
Memory-Optimized Tables Querying at the speed of light.
Data Warehouse ETL By Garrett EDmondson Thanks to our Gold Sponsors:
In-Memory Capabilities
Katowice,
Temporal Databases Microsoft SQL Server 2016
Antonio Abalos Castillo
Implementing Triggers
Finding more space for your tight environment
A Technical Overview of Microsoft® SQL Server™ 2005 High Availability Beta 2 Matthew Stephen IT Pro Evangelist (SQL Server)
Designing Database Solutions for SQL Server
Example of a page header
# - it’s not about social media it’s about temporary tables and data
# - it’s not about social media it’s about temporary tables and data
The Nitty-Gritty of Database Backups
Introduction to SQL Server Management for the Non-DBA
MDEV Cross-Engine SQL Backup
The Ins and Outs of Partitioned Tables
Database Administration for the Non-DBA
Download Latest Certification Practice Question Answers – Realexamdumps.com
Working with Very Large Tables Like a Pro in SQL Server 2014
Traveling in time with SQL Server 2017
Simple Partitioning Building a simple partitioning solution with SQL Server Stephen Fulcher.
Real world In-Memory OLTP
Microsoft SQL Server 2014 for Oracle DBAs Module 7
Realtime Analytics OLAP & OLTP in the mix
Sunil Agarwal | Principal Program Manager
RUM Conjecture of Database Access Method
Clustered Columnstore Indexes (SQL Server 2014)
Weird Stuff I Saw While … Working With Heaps
Partition Switching Joe Tempel.
Backup & Recovery.
Working with Very Large Tables Like a Pro in SQL Server 2017
Using Columnstore indexes in Azure DevOps Services. Lessons learned.
Presentation transcript:

Bulk Load and Minimal Logging Dean Savović Bulk Load and Minimal Logging

Sponsors

Agenda Minimal Logging Defined Minimal Logging Cross Reference Enhancements Methods Delete Update

Minimal Logging Defined Only full page BU Locking Batchsize Enable/disable triggers and constraints Input sort order (clustered target)

Minimal Logging Prereqs Simple or Bulk-logged recovery model TABLOCK (not always) Target table not replicated ALLOW_PAGE_LOCKS „ON” Backup

Minimally Logged Operations Bulk import operations (BCP, BULK INSERT and INSERT..SELECT) SELECT INTO operations TRUNCATE Starting in Sql server 2008 , INSERT SELECT statement can also be handled with minimal logging. Partial updates to large value data types, using the .WRITE clause. CREATE INDEX, ALTER INDEX REBUILD DROP TABLE Partition Switch Merge

Bulk Methods Integration Services Data Destinations BCP BULK INSERT SQL Server Destination OLE DB Destination BCP BULK INSERT INSERT … SELECT SELECT … INTO …

Minimal Logging Heap IsEmpty TABLOCK Locks Logging Concurrent Yes BU-Tab Minimal No IX-Tab Full

Data – minimal index – full Minimal Logging Heap + Non-Clustered Index IsEmpty TABLOCK Locks Logging Concurrent Yes Sch-M Minimal No IX-Tab Full Data – minimal index – full

Minimal Logging Clustered Index IsEmpty TABLOCK Locks Logging Concurrent Yes Sch-M Minimal No IX-Tab X-Tab Full

Minimal Logging Clustered Index + Non-Clustered Index IsEmpty TABLOCK Locks Logging Concurrent Yes Sch-M Depends No IX-Tab

Minimal Logging Columnstore Index 102400 NO TABLOCK

Minimal Logging Memory Optimized Always Fully Logged

Bulk Load Enhancements Select * Into dbo.TargetTable from dbo.SourceTable (SQL Server 2005-) Insert into dbo.TargetTable with (TABLOCK) select * from dbo.SourceTable (SQL Server 2008+) Insert into CI Btree (SQL Server 2008+) Order by Enable TF-610 Bulk insert (SQL Server 2008+) Without TABLOCK

Insert Scenarios

Comparison bulk insert dbo.tTable from 'd:\temp\tHeap.csv’ with ( formatfile = ‘D:\temp\bcp.fmt’ , rows_per_batch = 10000000 )

Heap No Indexes

Heap and Indexes

Clustered

Clustered And Non-Clus Indexes

Memory Optimized

Columnstore (CCI)

Comparison

Deleting a Large Amount of Rows in a Partition or Table in Minimally Logging Mode

Create a Copy of Main Table

Bulk load the rows you want to keep into the temporary partition INSERT INTO Sales_Temp WITH (TABLOCK) SELECT * FROM Sales WHERE OrderDate >=‘20010101’ AND OrderDate <‘20020101’ AND<Keep Criteria>

Switch out and truncate the old data

Rebuild indexes and use SWITCH ALTER TABLE Sales_Temp TO Sales SWITCH PARTITION 1

Drop the temporary table

Updating a Large Part of the Data in a Partition or a Table in Minimally Logged Mode

Write a change log to a temporary table

If the table is partitioned, switch out the partition you want to change ALTER TABLE Sales SWITCH PARTITION 1 TO Sales_Old

Merge the change log with the original table and bulk load to temporary table SELECT o.PrimaryKey ,COALESCE(d.Col1, o.Col1) , COALESCE(d.Col2, o.Col3) ... etc... FROM Sales_Old o LEFT JOIN Sales_Delta d

Delete the change log and original data DROP TABLE Sales_Delta DROP TABLE Sales_Old

SWITCH in the result of the merge ALTER TABLE Sales_New SWITCH TO Sales PARTITION 1 DROP TABLE Sales_New

EXEC [sys]. [sp_tableoption] @TableNamePattern = N'dbo EXEC [sys].[sp_tableoption] @TableNamePattern = N'dbo.BulkLoadTest’, @OptionName = 'table lock on bulk load’, @OptionValue = 'ON'

Evaluations Event Evaluation Session Evaluation http://www.sqlsaturday.com/764/EventEval.aspx Session Evaluation http://www.sqlsaturday.com/764/Sessions/SessionEvaluation.aspx

Sponsors

Questions?