SlideShare a Scribd company logo
1 of 24
Download to read offline
How minimal logging
can help me?
Bartosz Ratajczyk
#534 | KRAKÓW 2016
Our Sponsors
11/29/201
6 |
Footer Goes Here2 |
SQL SATURDAY | #534 | KRAKÓW 2016
Our Partners
11/29/201
6 |
Footer Goes Here3 |
The plan
• What is minimal logging?
• How does it work?
(and when?)
• What are the profits?
(and downsides)
• What is efficient logging?
• TRUNCATE TABLE logging?
SQL SATURDAY | #534 | KRAKÓW 2016
Bartosz Ratajczyk
SQL Server consultant
Database programmer
ETL programmer
Database administrator
MCSE: Data Platform, MCT, MCTS SQL Server 2008
http://bartekr.net | b.ratajczyk@gmail.com
SQL SATURDAY | #534 | KRAKÓW 2016
Transaction log
• Keeps track of every data modification in a
database
• Quantity of information saved in a
transaction log may depend on recovery
model
SQL SATURDAY | #534 | KRAKÓW 2016
Recovery models
• FULL
• allows point-in-time recovery
• requires log management
• BULK LOGGED
• point-in-time recovery not possible
• requires log management
• SIMPLE
• point-in-time recovery not possible
• takes care of log management
Minimal logging
„At a minimum, enough information has to be logged when
minimally logged operation is performed to allow SQL Server to
rollback a transaction that has failed.”
Kalen Delaney, SQL Server Internals 2012
„Minimal logging involves logging only the information that is
required to recover the transaction without supporting point-in-
time recovery.”
BOL: https://msdn.microsoft.com/en-us/library/ms191244.aspx
SQL SATURDAY | #534 | KRAKÓW 2016
Minimal logging (simplified)
• Contains only data alocation information *)
• So we save on I/O operations
BUT:
• Log does not contain all information required to
recover lost data
• Log backup will contain pages that changed
*) well, not exactly
SQL SATURDAY | #534 | KRAKÓW 2016
Logging types (simplified)
• Full – the operation has its own log record
• Efficient – the changed page has its own
log record
• Minimal – we log only page allocation
operations *)
*) well, not exactly
SQL SATURDAY | #534 | KRAKÓW 2016
Log investigation
SELECT *
FROM fn_dblog(NULL, NULL)
SELECT *
FROM fn_dblog(@StartLSN, @EndLSN)
SQL SATURDAY | #534 | KRAKÓW 2016
DEMO
Minimal logging
What can be minimally logged?
• BULK INSERT
• bcp
• SELECT INTO
• INSERT INTO .. SELECT
• CREATE INDEX
• ALTER INDEX REBUILD, DBCC DBREINDEX
• REORGANIZE always fully logged
• .WRITE
• WRITETEXT, UPDATETEXT
DEPRECATED
SQL SATURDAY | #534 | KRAKÓW 2016
Requirements summary
non-FULL recovery model
AND NOT replicated
AND (
(Heap AND TABLOCK)
OR (B-tree AND empty AND TABLOCK)
OR (B-tree AND empty AND TF-610)
OR (B-tree AND nonempty AND TF-610 AND
NEW key-range)
)
Source: Itzik Ben-Gan, http://sqlmag.com/t-sql/minimally-logged-inserts
SQL SATURDAY | #534 | KRAKÓW 2016
One more trick
If you can’t use TABLOCK then use:
EXEC sys.sp_tableoption
@TableNamePattern = N’dbo.Table’,
@OptionName = ’table lock on bulk load’,
@OptionValue = ’ON’
SQL SATURDAY | #534 | KRAKÓW 2016
Pros
• Faster transactions and log saving
• Smaller I/O
SQL SATURDAY | #534 | KRAKÓW 2016
And not pros
• Sensitive for data file errors
• Requires SIMPLE recovery model or switching
between FULL and BULK LOGGED
• So we won’t use Mirroring and Availability Groups
• But Log Shipping still can work
• May require TF 610 – sysadmin
• All data pages have to be written to disk before
transaction ends
SQL SATURDAY | #534 | KRAKÓW 2016
TRUNCATE TABLE
• Lightning fast data deletion
• Is it logged or not?
• Why is it so fast?
SQL SATURDAY | #534 | KRAKÓW 2016
DEMO
TRUNCATE TABLE
What to remember
• Minimal logging is just saving page
allocation information in transaction log *)
• It makes some operations quick, but is
sensitive for data file errors
• TRUNCATE is fully logged operation
*) well, not exactly
SQL SATURDAY | #534 | KRAKÓW 2016
Some things to read
• Itzik Ben-Gan „Minimally logged inserts: http://sqlmag.com/t-
sql/minimally-logged-inserts
• Gail Shaw, Tony Davis „Managing the Log in BULK_LOGGED
Recovery Model”
http://www.sqlservercentral.com/articles/Stairway+Series/94552/
• Paul Randall „The Myth that DROP and TRUNCATE TABLE are
Non-Logged” http://sqlperformance.com/2013/05/sql-
performance/drop-truncate-log-myth
• Remus Rusanu „How to read and interpret the SQL Server log”
http://rusanu.com/2014/03/10/how-to-read-and-interpret-the-sql-
server-log/
SQL SATURDAY | #534 | KRAKÓW 2016
Our Sponsors
11/29/201
6 |
Footer Goes Here22 |
SQL SATURDAY | #534 | KRAKÓW 2016
Our Partners
11/29/201
6 |
Footer Goes Here23 |
Bartosz Ratajczyk
#534 | KRAKÓW 2016

More Related Content

What's hot

Icinga Camp Bangalore - Icinga and Icinga Director
Icinga Camp Bangalore - Icinga and Icinga Director Icinga Camp Bangalore - Icinga and Icinga Director
Icinga Camp Bangalore - Icinga and Icinga Director Icinga
 
Icinga Camp Belgrade - Icinga Web 2
Icinga Camp Belgrade - Icinga Web 2Icinga Camp Belgrade - Icinga Web 2
Icinga Camp Belgrade - Icinga Web 2Icinga
 
Loadays 2015 - Enterprise Monitoring with Icinga
Loadays 2015 - Enterprise Monitoring with IcingaLoadays 2015 - Enterprise Monitoring with Icinga
Loadays 2015 - Enterprise Monitoring with IcingaIcinga
 
Introduction into Icinga Web 2
Introduction into Icinga Web 2Introduction into Icinga Web 2
Introduction into Icinga Web 2Icinga
 
The journey of Moving from AWS ELK to GCP Data Pipeline
The journey of Moving from AWS ELK to GCP Data PipelineThe journey of Moving from AWS ELK to GCP Data Pipeline
The journey of Moving from AWS ELK to GCP Data PipelineRandy Huang
 
Customizing Online Services for a Better Experience
Customizing Online Services for a Better ExperienceCustomizing Online Services for a Better Experience
Customizing Online Services for a Better ExperienceAPNIC
 
Sqlwatch presentation 2018-11
Sqlwatch presentation 2018-11Sqlwatch presentation 2018-11
Sqlwatch presentation 2018-11Marcin Gminski
 
Icinga Web 2 is more
Icinga Web 2 is moreIcinga Web 2 is more
Icinga Web 2 is moreIcinga
 
IcingaCamp Stockholm - Graphing with Graphite und Grafana
IcingaCamp Stockholm - Graphing with Graphite und GrafanaIcingaCamp Stockholm - Graphing with Graphite und Grafana
IcingaCamp Stockholm - Graphing with Graphite und GrafanaIcinga
 
Saluki - do it like a user
Saluki - do it like a userSaluki - do it like a user
Saluki - do it like a userIcinga
 
Icinga Camp Berlin 2018 - Dev and Ops Stories - Integrations++
Icinga Camp Berlin 2018 - Dev and Ops Stories - Integrations++Icinga Camp Berlin 2018 - Dev and Ops Stories - Integrations++
Icinga Camp Berlin 2018 - Dev and Ops Stories - Integrations++Icinga
 
informatica Online Training Institute in India,USA,UK,Canada.
informatica Online Training Institute in India,USA,UK,Canada.informatica Online Training Institute in India,USA,UK,Canada.
informatica Online Training Institute in India,USA,UK,Canada.Angel Maxwel
 
Icinga Camp San Francisco 2017 - Icinga Director - Managing your configuration
Icinga Camp San Francisco 2017 - Icinga Director - Managing your configurationIcinga Camp San Francisco 2017 - Icinga Director - Managing your configuration
Icinga Camp San Francisco 2017 - Icinga Director - Managing your configurationIcinga
 
Icinga Camp Amsterdam - Icinga Director
Icinga Camp Amsterdam - Icinga DirectorIcinga Camp Amsterdam - Icinga Director
Icinga Camp Amsterdam - Icinga DirectorIcinga
 
Icinga Camp Bangalore - Welcome
Icinga Camp Bangalore - WelcomeIcinga Camp Bangalore - Welcome
Icinga Camp Bangalore - WelcomeIcinga
 
Icinga Camp San Diego: Apify them all
Icinga Camp San Diego: Apify them allIcinga Camp San Diego: Apify them all
Icinga Camp San Diego: Apify them allIcinga
 
June 2018 spc recap visual
June 2018 spc recap visualJune 2018 spc recap visual
June 2018 spc recap visualCaitlin Young
 

What's hot (20)

Icinga Camp Bangalore - Icinga and Icinga Director
Icinga Camp Bangalore - Icinga and Icinga Director Icinga Camp Bangalore - Icinga and Icinga Director
Icinga Camp Bangalore - Icinga and Icinga Director
 
Icinga Camp Belgrade - Icinga Web 2
Icinga Camp Belgrade - Icinga Web 2Icinga Camp Belgrade - Icinga Web 2
Icinga Camp Belgrade - Icinga Web 2
 
Loadays 2015 - Enterprise Monitoring with Icinga
Loadays 2015 - Enterprise Monitoring with IcingaLoadays 2015 - Enterprise Monitoring with Icinga
Loadays 2015 - Enterprise Monitoring with Icinga
 
Introduction into Icinga Web 2
Introduction into Icinga Web 2Introduction into Icinga Web 2
Introduction into Icinga Web 2
 
The journey of Moving from AWS ELK to GCP Data Pipeline
The journey of Moving from AWS ELK to GCP Data PipelineThe journey of Moving from AWS ELK to GCP Data Pipeline
The journey of Moving from AWS ELK to GCP Data Pipeline
 
WEBridge 4 SAP ( Windchill and SAP Integration)
WEBridge 4 SAP ( Windchill and SAP Integration)WEBridge 4 SAP ( Windchill and SAP Integration)
WEBridge 4 SAP ( Windchill and SAP Integration)
 
Customizing Online Services for a Better Experience
Customizing Online Services for a Better ExperienceCustomizing Online Services for a Better Experience
Customizing Online Services for a Better Experience
 
Sqlwatch presentation 2018-11
Sqlwatch presentation 2018-11Sqlwatch presentation 2018-11
Sqlwatch presentation 2018-11
 
Icinga Web 2 is more
Icinga Web 2 is moreIcinga Web 2 is more
Icinga Web 2 is more
 
IcingaCamp Stockholm - Graphing with Graphite und Grafana
IcingaCamp Stockholm - Graphing with Graphite und GrafanaIcingaCamp Stockholm - Graphing with Graphite und Grafana
IcingaCamp Stockholm - Graphing with Graphite und Grafana
 
Saluki - do it like a user
Saluki - do it like a userSaluki - do it like a user
Saluki - do it like a user
 
Icinga Camp Berlin 2018 - Dev and Ops Stories - Integrations++
Icinga Camp Berlin 2018 - Dev and Ops Stories - Integrations++Icinga Camp Berlin 2018 - Dev and Ops Stories - Integrations++
Icinga Camp Berlin 2018 - Dev and Ops Stories - Integrations++
 
WEBridge 4 EBS ( Windchill and Oracle EBS Integration )
WEBridge 4 EBS ( Windchill and Oracle EBS Integration )WEBridge 4 EBS ( Windchill and Oracle EBS Integration )
WEBridge 4 EBS ( Windchill and Oracle EBS Integration )
 
informatica Online Training Institute in India,USA,UK,Canada.
informatica Online Training Institute in India,USA,UK,Canada.informatica Online Training Institute in India,USA,UK,Canada.
informatica Online Training Institute in India,USA,UK,Canada.
 
Icinga Camp San Francisco 2017 - Icinga Director - Managing your configuration
Icinga Camp San Francisco 2017 - Icinga Director - Managing your configurationIcinga Camp San Francisco 2017 - Icinga Director - Managing your configuration
Icinga Camp San Francisco 2017 - Icinga Director - Managing your configuration
 
Icinga Camp Amsterdam - Icinga Director
Icinga Camp Amsterdam - Icinga DirectorIcinga Camp Amsterdam - Icinga Director
Icinga Camp Amsterdam - Icinga Director
 
Icinga Camp Bangalore - Welcome
Icinga Camp Bangalore - WelcomeIcinga Camp Bangalore - Welcome
Icinga Camp Bangalore - Welcome
 
Icinga Camp San Diego: Apify them all
Icinga Camp San Diego: Apify them allIcinga Camp San Diego: Apify them all
Icinga Camp San Diego: Apify them all
 
June 2018 spc recap visual
June 2018 spc recap visualJune 2018 spc recap visual
June 2018 spc recap visual
 
Core FP Concepts
Core FP ConceptsCore FP Concepts
Core FP Concepts
 

Viewers also liked

Szkolenia i certyfikacjesqlserver2016_plssug99
Szkolenia i certyfikacjesqlserver2016_plssug99Szkolenia i certyfikacjesqlserver2016_plssug99
Szkolenia i certyfikacjesqlserver2016_plssug99Bartosz Ratajczyk
 
SQL Server 2016 JSON
SQL Server 2016 JSONSQL Server 2016 JSON
SQL Server 2016 JSONDavide Mauri
 
Azure Machine Learning
Azure Machine LearningAzure Machine Learning
Azure Machine LearningDavide Mauri
 
Back to the roots - SQL Server Indexing
Back to the roots - SQL Server IndexingBack to the roots - SQL Server Indexing
Back to the roots - SQL Server IndexingDavide Mauri
 
BIML: BI to the next level
BIML: BI to the next levelBIML: BI to the next level
BIML: BI to the next levelDavide Mauri
 
Azure ML: from basic to integration with custom applications
Azure ML: from basic to integration with custom applicationsAzure ML: from basic to integration with custom applications
Azure ML: from basic to integration with custom applicationsDavide Mauri
 
SSIS Monitoring Deep Dive
SSIS Monitoring Deep DiveSSIS Monitoring Deep Dive
SSIS Monitoring Deep DiveDavide Mauri
 
Azure Stream Analytics
Azure Stream AnalyticsAzure Stream Analytics
Azure Stream AnalyticsDavide Mauri
 
Event Hub & Azure Stream Analytics
Event Hub & Azure Stream AnalyticsEvent Hub & Azure Stream Analytics
Event Hub & Azure Stream AnalyticsDavide Mauri
 
SQL Server 2016 What's New For Developers
SQL Server 2016  What's New For DevelopersSQL Server 2016  What's New For Developers
SQL Server 2016 What's New For DevelopersDavide Mauri
 
Datarace: IoT e Big Data (Italian)
Datarace: IoT e Big Data (Italian)Datarace: IoT e Big Data (Italian)
Datarace: IoT e Big Data (Italian)Davide Mauri
 
Real Time Power BI
Real Time Power BIReal Time Power BI
Real Time Power BIDavide Mauri
 
AzureML - Creating and Using Machine Learning Solutions (Italian)
AzureML - Creating and Using Machine Learning Solutions (Italian)AzureML - Creating and Using Machine Learning Solutions (Italian)
AzureML - Creating and Using Machine Learning Solutions (Italian)Davide Mauri
 
Agile Data Warehousing
Agile Data WarehousingAgile Data Warehousing
Agile Data WarehousingDavide Mauri
 
Azure Machine Learning (Italian)
Azure Machine Learning (Italian)Azure Machine Learning (Italian)
Azure Machine Learning (Italian)Davide Mauri
 
Iris Multi-Class Classifier with Azure ML
Iris Multi-Class Classifier with Azure MLIris Multi-Class Classifier with Azure ML
Iris Multi-Class Classifier with Azure MLDavide Mauri
 
Dashboarding with Microsoft: Datazen & Power BI
Dashboarding with Microsoft: Datazen & Power BIDashboarding with Microsoft: Datazen & Power BI
Dashboarding with Microsoft: Datazen & Power BIDavide Mauri
 
SQL Server 2016 Temporal Tables
SQL Server 2016 Temporal TablesSQL Server 2016 Temporal Tables
SQL Server 2016 Temporal TablesDavide Mauri
 

Viewers also liked (20)

Podstawy ETL z SSIS
Podstawy ETL z SSISPodstawy ETL z SSIS
Podstawy ETL z SSIS
 
Szkolenia i certyfikacjesqlserver2016_plssug99
Szkolenia i certyfikacjesqlserver2016_plssug99Szkolenia i certyfikacjesqlserver2016_plssug99
Szkolenia i certyfikacjesqlserver2016_plssug99
 
SQL Server 2016 JSON
SQL Server 2016 JSONSQL Server 2016 JSON
SQL Server 2016 JSON
 
Azure Machine Learning
Azure Machine LearningAzure Machine Learning
Azure Machine Learning
 
Back to the roots - SQL Server Indexing
Back to the roots - SQL Server IndexingBack to the roots - SQL Server Indexing
Back to the roots - SQL Server Indexing
 
BIML: BI to the next level
BIML: BI to the next levelBIML: BI to the next level
BIML: BI to the next level
 
Azure ML: from basic to integration with custom applications
Azure ML: from basic to integration with custom applicationsAzure ML: from basic to integration with custom applications
Azure ML: from basic to integration with custom applications
 
SSIS Monitoring Deep Dive
SSIS Monitoring Deep DiveSSIS Monitoring Deep Dive
SSIS Monitoring Deep Dive
 
Azure Stream Analytics
Azure Stream AnalyticsAzure Stream Analytics
Azure Stream Analytics
 
Event Hub & Azure Stream Analytics
Event Hub & Azure Stream AnalyticsEvent Hub & Azure Stream Analytics
Event Hub & Azure Stream Analytics
 
SQL Server 2016 What's New For Developers
SQL Server 2016  What's New For DevelopersSQL Server 2016  What's New For Developers
SQL Server 2016 What's New For Developers
 
Datarace: IoT e Big Data (Italian)
Datarace: IoT e Big Data (Italian)Datarace: IoT e Big Data (Italian)
Datarace: IoT e Big Data (Italian)
 
Data juice
Data juiceData juice
Data juice
 
Real Time Power BI
Real Time Power BIReal Time Power BI
Real Time Power BI
 
AzureML - Creating and Using Machine Learning Solutions (Italian)
AzureML - Creating and Using Machine Learning Solutions (Italian)AzureML - Creating and Using Machine Learning Solutions (Italian)
AzureML - Creating and Using Machine Learning Solutions (Italian)
 
Agile Data Warehousing
Agile Data WarehousingAgile Data Warehousing
Agile Data Warehousing
 
Azure Machine Learning (Italian)
Azure Machine Learning (Italian)Azure Machine Learning (Italian)
Azure Machine Learning (Italian)
 
Iris Multi-Class Classifier with Azure ML
Iris Multi-Class Classifier with Azure MLIris Multi-Class Classifier with Azure ML
Iris Multi-Class Classifier with Azure ML
 
Dashboarding with Microsoft: Datazen & Power BI
Dashboarding with Microsoft: Datazen & Power BIDashboarding with Microsoft: Datazen & Power BI
Dashboarding with Microsoft: Datazen & Power BI
 
SQL Server 2016 Temporal Tables
SQL Server 2016 Temporal TablesSQL Server 2016 Temporal Tables
SQL Server 2016 Temporal Tables
 

Similar to How minimalloggingcanhelpme bartoszratajczyk_sql_sat534

2016 04 sqlsaturday_transaction_log
2016 04 sqlsaturday_transaction_log2016 04 sqlsaturday_transaction_log
2016 04 sqlsaturday_transaction_logHVR Software
 
Le novità di sql server 2019
Le novità di sql server 2019Le novità di sql server 2019
Le novità di sql server 2019Gianluca Hotz
 
SQL Server 2022 Programmability & Performance
SQL Server 2022 Programmability & PerformanceSQL Server 2022 Programmability & Performance
SQL Server 2022 Programmability & PerformanceGianluca Hotz
 
Fun Things to do with Logical Decoding
Fun Things to do with Logical DecodingFun Things to do with Logical Decoding
Fun Things to do with Logical DecodingMike Fowler
 
MariaDB 10.4 New Features
MariaDB 10.4 New FeaturesMariaDB 10.4 New Features
MariaDB 10.4 New FeaturesFromDual GmbH
 
Writing Futuristic Workflows in Office 365 SharePoint 2013 2016 on premise
Writing Futuristic Workflows in Office 365 SharePoint 2013 2016 on premiseWriting Futuristic Workflows in Office 365 SharePoint 2013 2016 on premise
Writing Futuristic Workflows in Office 365 SharePoint 2013 2016 on premisePrashant G Bhoyar (Microsoft MVP)
 
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_FeaturesAlfredo Abate
 
KoprowskiT_SQLRelay2014#4_Caerdydd_MaintenancePlansForBeginners
KoprowskiT_SQLRelay2014#4_Caerdydd_MaintenancePlansForBeginnersKoprowskiT_SQLRelay2014#4_Caerdydd_MaintenancePlansForBeginners
KoprowskiT_SQLRelay2014#4_Caerdydd_MaintenancePlansForBeginnersTobias Koprowski
 
Exploring plsql new features best practices september 2013
Exploring plsql new features best practices   september 2013Exploring plsql new features best practices   september 2013
Exploring plsql new features best practices september 2013Andrejs Vorobjovs
 
Recovery, logging and the transaction log
Recovery, logging and the transaction logRecovery, logging and the transaction log
Recovery, logging and the transaction logMiroslav Dimitrov
 
[JSS2015] AlwaysOn 2016
[JSS2015] AlwaysOn 2016[JSS2015] AlwaysOn 2016
[JSS2015] AlwaysOn 2016GUSS
 
Tailor azure log analytics with kusto queries
Tailor azure log analytics with kusto queriesTailor azure log analytics with kusto queries
Tailor azure log analytics with kusto queriesSamik Roy
 
Ten query tuning techniques every SQL Server programmer should know
Ten query tuning techniques every SQL Server programmer should knowTen query tuning techniques every SQL Server programmer should know
Ten query tuning techniques every SQL Server programmer should knowKevin Kline
 
MySQL 5.6 Replication Webinar
MySQL 5.6 Replication WebinarMySQL 5.6 Replication Webinar
MySQL 5.6 Replication WebinarMark Swarbrick
 
How to Develop Maintainable Custom Workflows in Office 365 Share Point Online?
How to Develop Maintainable Custom Workflows in Office 365 Share Point Online?How to Develop Maintainable Custom Workflows in Office 365 Share Point Online?
How to Develop Maintainable Custom Workflows in Office 365 Share Point Online?Prashant G Bhoyar (Microsoft MVP)
 
Monitoring sql server
Monitoring sql serverMonitoring sql server
Monitoring sql serverJohn Martin
 
Migrations from PLSQL and Transact-SQL - m18
Migrations from PLSQL and Transact-SQL - m18Migrations from PLSQL and Transact-SQL - m18
Migrations from PLSQL and Transact-SQL - m18Wagner Bianchi
 
M|18 Migrating from Oracle and Handling PL/SQL Stored Procedures
M|18 Migrating from Oracle and Handling PL/SQL Stored ProceduresM|18 Migrating from Oracle and Handling PL/SQL Stored Procedures
M|18 Migrating from Oracle and Handling PL/SQL Stored ProceduresMariaDB plc
 
Wtu 2014 ibm web sphere mq for zos - performance and accounting
Wtu 2014   ibm web sphere mq for zos - performance and accountingWtu 2014   ibm web sphere mq for zos - performance and accounting
Wtu 2014 ibm web sphere mq for zos - performance and accountingAlexander Ross
 

Similar to How minimalloggingcanhelpme bartoszratajczyk_sql_sat534 (20)

2016 04 sqlsaturday_transaction_log
2016 04 sqlsaturday_transaction_log2016 04 sqlsaturday_transaction_log
2016 04 sqlsaturday_transaction_log
 
Le novità di sql server 2019
Le novità di sql server 2019Le novità di sql server 2019
Le novità di sql server 2019
 
SQL Server 2022 Programmability & Performance
SQL Server 2022 Programmability & PerformanceSQL Server 2022 Programmability & Performance
SQL Server 2022 Programmability & Performance
 
Fun Things to do with Logical Decoding
Fun Things to do with Logical DecodingFun Things to do with Logical Decoding
Fun Things to do with Logical Decoding
 
MariaDB 10.4 New Features
MariaDB 10.4 New FeaturesMariaDB 10.4 New Features
MariaDB 10.4 New Features
 
Writing Futuristic Workflows in Office 365 SharePoint 2013 2016 on premise
Writing Futuristic Workflows in Office 365 SharePoint 2013 2016 on premiseWriting Futuristic Workflows in Office 365 SharePoint 2013 2016 on premise
Writing Futuristic Workflows in Office 365 SharePoint 2013 2016 on premise
 
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
 
KoprowskiT_SQLRelay2014#4_Caerdydd_MaintenancePlansForBeginners
KoprowskiT_SQLRelay2014#4_Caerdydd_MaintenancePlansForBeginnersKoprowskiT_SQLRelay2014#4_Caerdydd_MaintenancePlansForBeginners
KoprowskiT_SQLRelay2014#4_Caerdydd_MaintenancePlansForBeginners
 
Exploring plsql new features best practices september 2013
Exploring plsql new features best practices   september 2013Exploring plsql new features best practices   september 2013
Exploring plsql new features best practices september 2013
 
Recovery, logging and the transaction log
Recovery, logging and the transaction logRecovery, logging and the transaction log
Recovery, logging and the transaction log
 
[JSS2015] AlwaysOn 2016
[JSS2015] AlwaysOn 2016[JSS2015] AlwaysOn 2016
[JSS2015] AlwaysOn 2016
 
Tailor azure log analytics with kusto queries
Tailor azure log analytics with kusto queriesTailor azure log analytics with kusto queries
Tailor azure log analytics with kusto queries
 
Ten query tuning techniques every SQL Server programmer should know
Ten query tuning techniques every SQL Server programmer should knowTen query tuning techniques every SQL Server programmer should know
Ten query tuning techniques every SQL Server programmer should know
 
MySQL 5.6 Replication Webinar
MySQL 5.6 Replication WebinarMySQL 5.6 Replication Webinar
MySQL 5.6 Replication Webinar
 
How to Develop Maintainable Custom Workflows in Office 365 Share Point Online?
How to Develop Maintainable Custom Workflows in Office 365 Share Point Online?How to Develop Maintainable Custom Workflows in Office 365 Share Point Online?
How to Develop Maintainable Custom Workflows in Office 365 Share Point Online?
 
Monitoring sql server
Monitoring sql serverMonitoring sql server
Monitoring sql server
 
Migrations from PLSQL and Transact-SQL - m18
Migrations from PLSQL and Transact-SQL - m18Migrations from PLSQL and Transact-SQL - m18
Migrations from PLSQL and Transact-SQL - m18
 
M|18 Migrating from Oracle and Handling PL/SQL Stored Procedures
M|18 Migrating from Oracle and Handling PL/SQL Stored ProceduresM|18 Migrating from Oracle and Handling PL/SQL Stored Procedures
M|18 Migrating from Oracle and Handling PL/SQL Stored Procedures
 
Wtu 2014 ibm web sphere mq for zos - performance and accounting
Wtu 2014   ibm web sphere mq for zos - performance and accountingWtu 2014   ibm web sphere mq for zos - performance and accounting
Wtu 2014 ibm web sphere mq for zos - performance and accounting
 
Advanced Office365 Sharepoint online Workflows
Advanced Office365 Sharepoint online WorkflowsAdvanced Office365 Sharepoint online Workflows
Advanced Office365 Sharepoint online Workflows
 

More from Bartosz Ratajczyk

SQL Server + docker - pierwsze kroki
SQL Server + docker - pierwsze krokiSQL Server + docker - pierwsze kroki
SQL Server + docker - pierwsze krokiBartosz Ratajczyk
 
OLE DB - kiedy FastLoad nie jest takie fast
OLE DB - kiedy FastLoad nie jest takie fastOLE DB - kiedy FastLoad nie jest takie fast
OLE DB - kiedy FastLoad nie jest takie fastBartosz Ratajczyk
 
Jak działa rekurencyjne CTE?
Jak działa rekurencyjne CTE?Jak działa rekurencyjne CTE?
Jak działa rekurencyjne CTE?Bartosz Ratajczyk
 
SqlSaturday Denmark 2017 - Automate your SSIS deployment process
SqlSaturday Denmark 2017 - Automate your SSIS deployment processSqlSaturday Denmark 2017 - Automate your SSIS deployment process
SqlSaturday Denmark 2017 - Automate your SSIS deployment processBartosz Ratajczyk
 
"Administrator z przypadku" - Jak działa SQL Server i jak o niego dbać
"Administrator z przypadku" - Jak działa SQL Server i jak o niego dbać"Administrator z przypadku" - Jak działa SQL Server i jak o niego dbać
"Administrator z przypadku" - Jak działa SQL Server i jak o niego dbaćBartosz Ratajczyk
 
Zautomatyzuj swój proces wdrażania projektów SSIS
Zautomatyzuj swój proces wdrażania projektów SSISZautomatyzuj swój proces wdrażania projektów SSIS
Zautomatyzuj swój proces wdrażania projektów SSISBartosz Ratajczyk
 
Jak szybko przetwarzasz hurtowe ilości XML?
Jak szybko przetwarzasz hurtowe ilości XML?Jak szybko przetwarzasz hurtowe ilości XML?
Jak szybko przetwarzasz hurtowe ilości XML?Bartosz Ratajczyk
 
Operacje minimalnie logowane
Operacje minimalnie logowaneOperacje minimalnie logowane
Operacje minimalnie logowaneBartosz Ratajczyk
 
Czy mi się przyda hierarchyid?
Czy mi się przyda hierarchyid?Czy mi się przyda hierarchyid?
Czy mi się przyda hierarchyid?Bartosz Ratajczyk
 

More from Bartosz Ratajczyk (14)

SQL Server + docker - pierwsze kroki
SQL Server + docker - pierwsze krokiSQL Server + docker - pierwsze kroki
SQL Server + docker - pierwsze kroki
 
OLE DB - kiedy FastLoad nie jest takie fast
OLE DB - kiedy FastLoad nie jest takie fastOLE DB - kiedy FastLoad nie jest takie fast
OLE DB - kiedy FastLoad nie jest takie fast
 
Jak działa rekurencyjne CTE?
Jak działa rekurencyjne CTE?Jak działa rekurencyjne CTE?
Jak działa rekurencyjne CTE?
 
SqlSaturday Denmark 2017 - Automate your SSIS deployment process
SqlSaturday Denmark 2017 - Automate your SSIS deployment processSqlSaturday Denmark 2017 - Automate your SSIS deployment process
SqlSaturday Denmark 2017 - Automate your SSIS deployment process
 
"Administrator z przypadku" - Jak działa SQL Server i jak o niego dbać
"Administrator z przypadku" - Jak działa SQL Server i jak o niego dbać"Administrator z przypadku" - Jak działa SQL Server i jak o niego dbać
"Administrator z przypadku" - Jak działa SQL Server i jak o niego dbać
 
Zautomatyzuj swój proces wdrażania projektów SSIS
Zautomatyzuj swój proces wdrażania projektów SSISZautomatyzuj swój proces wdrażania projektów SSIS
Zautomatyzuj swój proces wdrażania projektów SSIS
 
XML w SQL Server w praktyce
XML w SQL Server w praktyceXML w SQL Server w praktyce
XML w SQL Server w praktyce
 
Jak szybko przetwarzasz hurtowe ilości XML?
Jak szybko przetwarzasz hurtowe ilości XML?Jak szybko przetwarzasz hurtowe ilości XML?
Jak szybko przetwarzasz hurtowe ilości XML?
 
Operacje minimalnie logowane
Operacje minimalnie logowaneOperacje minimalnie logowane
Operacje minimalnie logowane
 
Po co mi Temporal Tables?
Po co mi Temporal Tables?Po co mi Temporal Tables?
Po co mi Temporal Tables?
 
Co to te CTE?
Co to te CTE?Co to te CTE?
Co to te CTE?
 
O co chodzi z FILESTREAM?
O co chodzi z FILESTREAM?O co chodzi z FILESTREAM?
O co chodzi z FILESTREAM?
 
Alerty WMI
Alerty WMIAlerty WMI
Alerty WMI
 
Czy mi się przyda hierarchyid?
Czy mi się przyda hierarchyid?Czy mi się przyda hierarchyid?
Czy mi się przyda hierarchyid?
 

Recently uploaded

Benefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive EducationBenefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive EducationMJDuyan
 
How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17Celine George
 
Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.EnglishCEIPdeSigeiro
 
The basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxThe basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxheathfieldcps1
 
Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...raviapr7
 
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRADUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRATanmoy Mishra
 
Education and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxEducation and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxraviapr7
 
How to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesHow to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesCeline George
 
HED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfHED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfMohonDas
 
How to Solve Singleton Error in the Odoo 17
How to Solve Singleton Error in the  Odoo 17How to Solve Singleton Error in the  Odoo 17
How to Solve Singleton Error in the Odoo 17Celine George
 
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptxClinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptxraviapr7
 
Maximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdf
Maximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdfMaximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdf
Maximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdfTechSoup
 
Human-AI Co-Creation of Worked Examples for Programming Classes
Human-AI Co-Creation of Worked Examples for Programming ClassesHuman-AI Co-Creation of Worked Examples for Programming Classes
Human-AI Co-Creation of Worked Examples for Programming ClassesMohammad Hassany
 
How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17Celine George
 
How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17Celine George
 
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptxPISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptxEduSkills OECD
 
Practical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptxPractical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptxKatherine Villaluna
 
3.21.24 The Origins of Black Power.pptx
3.21.24  The Origins of Black Power.pptx3.21.24  The Origins of Black Power.pptx
3.21.24 The Origins of Black Power.pptxmary850239
 
How to Add a many2many Relational Field in Odoo 17
How to Add a many2many Relational Field in Odoo 17How to Add a many2many Relational Field in Odoo 17
How to Add a many2many Relational Field in Odoo 17Celine George
 

Recently uploaded (20)

Benefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive EducationBenefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive Education
 
Prelims of Kant get Marx 2.0: a general politics quiz
Prelims of Kant get Marx 2.0: a general politics quizPrelims of Kant get Marx 2.0: a general politics quiz
Prelims of Kant get Marx 2.0: a general politics quiz
 
How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17
 
Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.
 
The basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxThe basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptx
 
Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...
 
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRADUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
 
Education and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxEducation and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptx
 
How to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesHow to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 Sales
 
HED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfHED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdf
 
How to Solve Singleton Error in the Odoo 17
How to Solve Singleton Error in the  Odoo 17How to Solve Singleton Error in the  Odoo 17
How to Solve Singleton Error in the Odoo 17
 
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptxClinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptx
 
Maximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdf
Maximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdfMaximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdf
Maximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdf
 
Human-AI Co-Creation of Worked Examples for Programming Classes
Human-AI Co-Creation of Worked Examples for Programming ClassesHuman-AI Co-Creation of Worked Examples for Programming Classes
Human-AI Co-Creation of Worked Examples for Programming Classes
 
How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17
 
How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17
 
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptxPISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
 
Practical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptxPractical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptx
 
3.21.24 The Origins of Black Power.pptx
3.21.24  The Origins of Black Power.pptx3.21.24  The Origins of Black Power.pptx
3.21.24 The Origins of Black Power.pptx
 
How to Add a many2many Relational Field in Odoo 17
How to Add a many2many Relational Field in Odoo 17How to Add a many2many Relational Field in Odoo 17
How to Add a many2many Relational Field in Odoo 17
 

How minimalloggingcanhelpme bartoszratajczyk_sql_sat534

  • 1. How minimal logging can help me? Bartosz Ratajczyk #534 | KRAKÓW 2016
  • 2. Our Sponsors 11/29/201 6 | Footer Goes Here2 | SQL SATURDAY | #534 | KRAKÓW 2016
  • 4. The plan • What is minimal logging? • How does it work? (and when?) • What are the profits? (and downsides) • What is efficient logging? • TRUNCATE TABLE logging? SQL SATURDAY | #534 | KRAKÓW 2016
  • 5. Bartosz Ratajczyk SQL Server consultant Database programmer ETL programmer Database administrator MCSE: Data Platform, MCT, MCTS SQL Server 2008 http://bartekr.net | b.ratajczyk@gmail.com SQL SATURDAY | #534 | KRAKÓW 2016
  • 6. Transaction log • Keeps track of every data modification in a database • Quantity of information saved in a transaction log may depend on recovery model SQL SATURDAY | #534 | KRAKÓW 2016
  • 7. Recovery models • FULL • allows point-in-time recovery • requires log management • BULK LOGGED • point-in-time recovery not possible • requires log management • SIMPLE • point-in-time recovery not possible • takes care of log management
  • 8. Minimal logging „At a minimum, enough information has to be logged when minimally logged operation is performed to allow SQL Server to rollback a transaction that has failed.” Kalen Delaney, SQL Server Internals 2012 „Minimal logging involves logging only the information that is required to recover the transaction without supporting point-in- time recovery.” BOL: https://msdn.microsoft.com/en-us/library/ms191244.aspx SQL SATURDAY | #534 | KRAKÓW 2016
  • 9. Minimal logging (simplified) • Contains only data alocation information *) • So we save on I/O operations BUT: • Log does not contain all information required to recover lost data • Log backup will contain pages that changed *) well, not exactly SQL SATURDAY | #534 | KRAKÓW 2016
  • 10. Logging types (simplified) • Full – the operation has its own log record • Efficient – the changed page has its own log record • Minimal – we log only page allocation operations *) *) well, not exactly SQL SATURDAY | #534 | KRAKÓW 2016
  • 11. Log investigation SELECT * FROM fn_dblog(NULL, NULL) SELECT * FROM fn_dblog(@StartLSN, @EndLSN) SQL SATURDAY | #534 | KRAKÓW 2016
  • 13. What can be minimally logged? • BULK INSERT • bcp • SELECT INTO • INSERT INTO .. SELECT • CREATE INDEX • ALTER INDEX REBUILD, DBCC DBREINDEX • REORGANIZE always fully logged • .WRITE • WRITETEXT, UPDATETEXT DEPRECATED SQL SATURDAY | #534 | KRAKÓW 2016
  • 14. Requirements summary non-FULL recovery model AND NOT replicated AND ( (Heap AND TABLOCK) OR (B-tree AND empty AND TABLOCK) OR (B-tree AND empty AND TF-610) OR (B-tree AND nonempty AND TF-610 AND NEW key-range) ) Source: Itzik Ben-Gan, http://sqlmag.com/t-sql/minimally-logged-inserts SQL SATURDAY | #534 | KRAKÓW 2016
  • 15. One more trick If you can’t use TABLOCK then use: EXEC sys.sp_tableoption @TableNamePattern = N’dbo.Table’, @OptionName = ’table lock on bulk load’, @OptionValue = ’ON’ SQL SATURDAY | #534 | KRAKÓW 2016
  • 16. Pros • Faster transactions and log saving • Smaller I/O SQL SATURDAY | #534 | KRAKÓW 2016
  • 17. And not pros • Sensitive for data file errors • Requires SIMPLE recovery model or switching between FULL and BULK LOGGED • So we won’t use Mirroring and Availability Groups • But Log Shipping still can work • May require TF 610 – sysadmin • All data pages have to be written to disk before transaction ends SQL SATURDAY | #534 | KRAKÓW 2016
  • 18. TRUNCATE TABLE • Lightning fast data deletion • Is it logged or not? • Why is it so fast? SQL SATURDAY | #534 | KRAKÓW 2016
  • 20. What to remember • Minimal logging is just saving page allocation information in transaction log *) • It makes some operations quick, but is sensitive for data file errors • TRUNCATE is fully logged operation *) well, not exactly SQL SATURDAY | #534 | KRAKÓW 2016
  • 21. Some things to read • Itzik Ben-Gan „Minimally logged inserts: http://sqlmag.com/t- sql/minimally-logged-inserts • Gail Shaw, Tony Davis „Managing the Log in BULK_LOGGED Recovery Model” http://www.sqlservercentral.com/articles/Stairway+Series/94552/ • Paul Randall „The Myth that DROP and TRUNCATE TABLE are Non-Logged” http://sqlperformance.com/2013/05/sql- performance/drop-truncate-log-myth • Remus Rusanu „How to read and interpret the SQL Server log” http://rusanu.com/2014/03/10/how-to-read-and-interpret-the-sql- server-log/ SQL SATURDAY | #534 | KRAKÓW 2016
  • 22. Our Sponsors 11/29/201 6 | Footer Goes Here22 | SQL SATURDAY | #534 | KRAKÓW 2016
  • 24. Bartosz Ratajczyk #534 | KRAKÓW 2016