{"id":4773,"date":"2015-05-18T12:39:26","date_gmt":"2015-05-18T10:39:26","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/variations-on-1m-insert-2-write-commit\/"},"modified":"2015-05-18T12:39:26","modified_gmt":"2015-05-18T10:39:26","slug":"variations-on-1m-insert-2-write-commit","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/variations-on-1m-insert-2-write-commit\/","title":{"rendered":"Variations on 1M insert (2): write commit"},"content":{"rendered":"<p>In this blog post, I will try to do the same than my colleagues about <a href=\"http:\/\/dbi-services.com\/blog\/variations-on-1m-rows-insert-1-bulk-insert\/\" target=\"_blank\" rel=\"noopener noreferrer\">Oracle<\/a> and for <a href=\"http:\/\/dbi-services.com\/blog\/the-fastest-way-to-load-1m-rows-in-postgresql\/\">PostgreSQL<\/a>. As a reminder, we\u2019ve seen in my <a href=\"https:\/\/www.dbi-services.com\/index.php\/blog\/entry\/variations-on-1m-rows-insert-1-bulk-insert\">previous blog post<\/a> that SQL Server is designed to commit transactions implicitly by default and inserting 1M rows in this case may have a huge impact on the transaction log throughput. Each transaction is synchronously committed to the transaction log. In this blog post, we\u2019ll see a variation of the previous test<\/p>\n<p>Indeed, since SQL Server 2014 version, it is possible to change a little bit this behaviour to improve the overall performance of our test by using a feature called delayed durability transaction. This is a performance feature for sure but you will have to trade durability for performance. As explained <a href=\"https:\/\/www.dbi-services.com\/index.php\/blog\/entry\/sql-server-2014-classic-commit-vs-commit-with-delayed-durability-and-ios\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>, SQL Server uses a write-ahead logging protocol (WAL) and using this new feature will temporarily suspend this requirement.<\/p>\n<p>So, let\u2019s perform the same test but this time I will favour the overall throughput performance by using delayed durability option.<\/p>\n<p><code>alter database demo set delayed_durability = allowed;<br \/>\ngo<br \/>\nDECLARE @i INT = 1;<br \/>\nWHILE @i &lt;= 1000000<br \/>\nBEGIN<br \/>\nbegin tran;<br \/>\nINSERT INTO DEMO VALUES (@i, CASE ROUND(RAND() * 10, 0) WHEN 1 THEN 'Marc' WHEN 2 THEN'Bill' WHEN 3 THEN 'George' WHEN 4 THEN 'Eliot' WHEN 5 THEN 'Matt' WHEN 6 THEN 'Trey' ELSE'Tracy' END, RAND() * 10000);<br \/>\ncommit tran with (delayed_durability = on);<br \/>\nSET @i += 1;<br \/>\nEND<\/code><\/p>\n<div><strong>&#8212; 00:00:20 \u2013 Heap table<\/strong><\/div>\n<div><strong>&#8212; 00:00:19 \u2013 table with clustered index<\/strong><\/div>\n<p>If I refer to my <a href=\"http:\/\/dbi-services.com\/blog\/variations-on-1m-rows-insert-1-bulk-insert\/\">first test results<\/a> with implicit commit behaviour, I may effectively notice a big performance improvement (86%). You may also note that I used this option at the transaction level after enabling delayed durability at the database level but in fact you have other <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/dn449490.aspx\">possibilities<\/a>. Depending on your context, you may prefer either to enable or to force this option directly at the database level.<\/p>\n<p>Do I have to enable it? If your business is comfortable making throughput versus durability and this option improves the overall performance, go ahead but keep in mind that you also have others ways to improve your transaction log throughput before enabling this option (please read the Paul Randal\u2019s <a href=\"http:\/\/www.sqlskills.com\/blogs\/paul\/delayed-durability-sql-server-2014\/\">blog posts<\/a>)<\/p>\n<p>Want to meet in one day our experts from all technologies? Come to our <a href=\"https:\/\/www.dbi-services.com\/index.php\/newsroom-e\/events\/event-l-in-memory-r-boost-your-it-performance\">Event In-Memory: boost your IT performance!<\/a>\u00a0where we talk about SQL Server, Oracle and SAP HANA.<\/p>\n<p>By David Barbarin<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog post, I will try to do the same than my colleagues about Oracle and for PostgreSQL. As a reminder, we\u2019ve seen in my previous blog post that SQL Server is designed to commit transactions implicitly by default and inserting 1M rows in this case may have a huge impact on the transaction [&hellip;]<\/p>\n","protected":false},"author":26,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[368],"tags":[67,51,52],"type_dbi":[],"class_list":["post-4773","post","type-post","status-publish","format-standard","hentry","category-development-performance","tag-performance","tag-sql-server","tag-sql-server-2014"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.2 (Yoast SEO v27.2) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Variations on 1M insert (2): write commit - dbi Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.dbi-services.com\/blog\/variations-on-1m-insert-2-write-commit\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Variations on 1M insert (2): write commit\" \/>\n<meta property=\"og:description\" content=\"In this blog post, I will try to do the same than my colleagues about Oracle and for PostgreSQL. As a reminder, we\u2019ve seen in my previous blog post that SQL Server is designed to commit transactions implicitly by default and inserting 1M rows in this case may have a huge impact on the transaction [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/variations-on-1m-insert-2-write-commit\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi Blog\" \/>\n<meta property=\"article:published_time\" content=\"2015-05-18T10:39:26+00:00\" \/>\n<meta name=\"author\" content=\"Microsoft Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Microsoft Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/variations-on-1m-insert-2-write-commit\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/variations-on-1m-insert-2-write-commit\/\"},\"author\":{\"name\":\"Microsoft Team\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/bfab48333280d616e1170e7369df90a4\"},\"headline\":\"Variations on 1M insert (2): write commit\",\"datePublished\":\"2015-05-18T10:39:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/variations-on-1m-insert-2-write-commit\/\"},\"wordCount\":337,\"commentCount\":0,\"keywords\":[\"Performance\",\"SQL Server\",\"SQL Server 2014\"],\"articleSection\":[\"Development &amp; Performance\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.dbi-services.com\/blog\/variations-on-1m-insert-2-write-commit\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/variations-on-1m-insert-2-write-commit\/\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/variations-on-1m-insert-2-write-commit\/\",\"name\":\"Variations on 1M insert (2): write commit - dbi Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\"},\"datePublished\":\"2015-05-18T10:39:26+00:00\",\"author\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/bfab48333280d616e1170e7369df90a4\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/variations-on-1m-insert-2-write-commit\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.dbi-services.com\/blog\/variations-on-1m-insert-2-write-commit\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/variations-on-1m-insert-2-write-commit\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\/\/www.dbi-services.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Variations on 1M insert (2): write commit\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/\",\"name\":\"dbi Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/bfab48333280d616e1170e7369df90a4\",\"name\":\"Microsoft Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/c44a1a792c059f24055763aa77d80a244467f6eef724a8bd13db8d4a350b7a4c?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c44a1a792c059f24055763aa77d80a244467f6eef724a8bd13db8d4a350b7a4c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c44a1a792c059f24055763aa77d80a244467f6eef724a8bd13db8d4a350b7a4c?s=96&d=mm&r=g\",\"caption\":\"Microsoft Team\"},\"url\":\"https:\/\/www.dbi-services.com\/blog\/author\/microsoft-team\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Variations on 1M insert (2): write commit - dbi Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.dbi-services.com\/blog\/variations-on-1m-insert-2-write-commit\/","og_locale":"en_US","og_type":"article","og_title":"Variations on 1M insert (2): write commit","og_description":"In this blog post, I will try to do the same than my colleagues about Oracle and for PostgreSQL. As a reminder, we\u2019ve seen in my previous blog post that SQL Server is designed to commit transactions implicitly by default and inserting 1M rows in this case may have a huge impact on the transaction [&hellip;]","og_url":"https:\/\/www.dbi-services.com\/blog\/variations-on-1m-insert-2-write-commit\/","og_site_name":"dbi Blog","article_published_time":"2015-05-18T10:39:26+00:00","author":"Microsoft Team","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Microsoft Team","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dbi-services.com\/blog\/variations-on-1m-insert-2-write-commit\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/variations-on-1m-insert-2-write-commit\/"},"author":{"name":"Microsoft Team","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/bfab48333280d616e1170e7369df90a4"},"headline":"Variations on 1M insert (2): write commit","datePublished":"2015-05-18T10:39:26+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/variations-on-1m-insert-2-write-commit\/"},"wordCount":337,"commentCount":0,"keywords":["Performance","SQL Server","SQL Server 2014"],"articleSection":["Development &amp; Performance"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/variations-on-1m-insert-2-write-commit\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/variations-on-1m-insert-2-write-commit\/","url":"https:\/\/www.dbi-services.com\/blog\/variations-on-1m-insert-2-write-commit\/","name":"Variations on 1M insert (2): write commit - dbi Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"datePublished":"2015-05-18T10:39:26+00:00","author":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/bfab48333280d616e1170e7369df90a4"},"breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/variations-on-1m-insert-2-write-commit\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/variations-on-1m-insert-2-write-commit\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/variations-on-1m-insert-2-write-commit\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Variations on 1M insert (2): write commit"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/bfab48333280d616e1170e7369df90a4","name":"Microsoft Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/c44a1a792c059f24055763aa77d80a244467f6eef724a8bd13db8d4a350b7a4c?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/c44a1a792c059f24055763aa77d80a244467f6eef724a8bd13db8d4a350b7a4c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c44a1a792c059f24055763aa77d80a244467f6eef724a8bd13db8d4a350b7a4c?s=96&d=mm&r=g","caption":"Microsoft Team"},"url":"https:\/\/www.dbi-services.com\/blog\/author\/microsoft-team\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/4773","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/users\/26"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/comments?post=4773"}],"version-history":[{"count":0,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/4773\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=4773"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=4773"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=4773"},{"taxonomy":"type","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/type_dbi?post=4773"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}