{"id":1545,"date":"2023-10-24T11:32:59","date_gmt":"2023-10-24T11:32:59","guid":{"rendered":"https:\/\/www.hammerdb.com\/blog\/?p=1545"},"modified":"2023-10-24T11:32:59","modified_gmt":"2023-10-24T11:32:59","slug":"hammerdb-v4-9-new-feature-accelerate-sql-server-builds-with-bcp","status":"publish","type":"post","link":"https:\/\/www.hammerdb.com\/blog\/uncategorized\/hammerdb-v4-9-new-feature-accelerate-sql-server-builds-with-bcp\/","title":{"rendered":"HammerDB v4.9 New Feature: Accelerate SQL Server builds with BCP"},"content":{"rendered":"<p>This post provides an introduction to the new feature added to HammerDB v4.9 by <a class=\"user-mention notranslate\" href=\"https:\/\/github.com\/krithikasatish\" data-hovercard-type=\"user\" data-hovercard-url=\"\/users\/krithikasatish\/hovercard\" data-octo-click=\"hovercard-link-click\" data-octo-dimensions=\"link_type:self\">@krithikasatish<\/a>\u00a0 and <a class=\"user-mention notranslate\" href=\"https:\/\/github.com\/JoshInnis\" data-hovercard-type=\"user\" data-hovercard-url=\"\/users\/JoshInnis\/hovercard\" data-octo-click=\"hovercard-link-click\" data-octo-dimensions=\"link_type:self\">@JoshInnis<\/a> to provide accelerated load performance for both SQL Server TPROC-C and TPROC-H schemas.<\/p>\n<p>This accelerated load is implemented using the <a href=\"https:\/\/learn.microsoft.com\/en-us\/sql\/tools\/bcp-utility?view=sql-server-ver16\">BCP<\/a> utility and is turned on or off with the &#8220;Use BCP Option&#8221; checkbox. With the default for v4.9 to have this feature enabled.<\/p>\n<h2>Insert based load<\/h2>\n<p>In previous releases, HammerDB loads data using inserts, (or supported a manual use of BCP by generating flat files with the <a href=\"https:\/\/www.hammerdb.com\/docs\/ch13s01.html\">datagen<\/a> option) and you can still perform schema loads with inserts by deselecting the Use BCP Option.<\/p>\n<p><a href=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2023\/10\/no_bcp.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1547\" src=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2023\/10\/no_bcp.png\" alt=\"\" width=\"397\" height=\"560\" srcset=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2023\/10\/no_bcp.png 397w, https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2023\/10\/no_bcp-213x300.png 213w\" sizes=\"auto, (max-width: 397px) 100vw, 397px\" \/><\/a><\/p>\n<p>This earlier functionality has the advantage that there are no intermediate staging files required, and data is inserted into the database with multi-row inserts as soon as it is created. The disadvantage of this approach is that the database sees the insert as a regular database insert, maintaining consistency and recoverability, and with a round-trip to the HammerDB client per multi-row, this is what we see in recent expensive queries.<\/p>\n<p><a href=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2023\/10\/nobcp_sql.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1558\" src=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2023\/10\/nobcp_sql.png\" alt=\"\" width=\"863\" height=\"136\" srcset=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2023\/10\/nobcp_sql.png 863w, https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2023\/10\/nobcp_sql-300x47.png 300w, https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2023\/10\/nobcp_sql-768x121.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/a><\/p>\n<p>In this example on a development PC the regular build started at 10:48:35 and ended at 10:54:46 meaning it took 6 minutes 11 seconds to build our 20 warehouse schema.<\/p>\n<h2>BCP based load<\/h2>\n<p>Now when we select the\u00a0 &#8220;Use BCP Option&#8221;<\/p>\n<p><a href=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2023\/10\/bcp_option.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1551\" src=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2023\/10\/bcp_option.png\" alt=\"\" width=\"397\" height=\"560\" srcset=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2023\/10\/bcp_option.png 397w, https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2023\/10\/bcp_option-213x300.png 213w\" sizes=\"auto, (max-width: 397px) 100vw, 397px\" \/><\/a><\/p>\n<p>We can see that we are now using an insert bulk command (although the item table being fixed at 100K rows and loaded by the monitor virtual user continues to use regular inserts).<\/p>\n<p><a href=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2023\/10\/active_bcp.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1554\" src=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2023\/10\/active_bcp.png\" alt=\"\" width=\"861\" height=\"114\" srcset=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2023\/10\/active_bcp.png 861w, https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2023\/10\/active_bcp-300x40.png 300w, https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2023\/10\/active_bcp-768x102.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/a><\/p>\n<p>In our PC test the build started at 11:28:16 and ended at 11:30:27 meaning it took 2 minutes 11 seconds to build our 20 warehouse schema.<\/p>\n<p>Using BCP our TPROC-C build now completed almost 3X faster and tests on TPROC-H showed similar results.<\/p>\n<p>Note that for the BCP functionality, temporary data files will be created and deleted in the TMP environment variable area, and you can find this location by running the command<\/p>\n<pre>(HammerDB-4.9) % puts $::env(TMP)\r\nC:\\Users\\Hammer\\AppData\\Local\\Temp<\/pre>\n<p>in the HammerDB console, and then see the files being created and deleted as the build progresses.<\/p>\n<p><a href=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2023\/10\/bcp_temp.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1560\" src=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2023\/10\/bcp_temp.png\" alt=\"\" width=\"672\" height=\"130\" srcset=\"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2023\/10\/bcp_temp.png 672w, https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2023\/10\/bcp_temp-300x58.png 300w\" sizes=\"auto, (max-width: 672px) 100vw, 672px\" \/><\/a><\/p>\n<h2>Summary<\/h2>\n<p>The new Use BCP Option for SQL Server accelerates both TPROC-C and TPROC-H schema loads, so you can get to running your benchmarks faster. We thank <a class=\"user-mention notranslate\" href=\"https:\/\/github.com\/krithikasatish\" data-hovercard-type=\"user\" data-hovercard-url=\"\/users\/krithikasatish\/hovercard\" data-octo-click=\"hovercard-link-click\" data-octo-dimensions=\"link_type:self\">@krithikasatish<\/a> and <a class=\"user-mention notranslate\" href=\"https:\/\/github.com\/JoshInnis\" data-hovercard-type=\"user\" data-hovercard-url=\"\/users\/JoshInnis\/hovercard\" data-octo-click=\"hovercard-link-click\" data-octo-dimensions=\"link_type:self\">@JoshInnis<\/a> for this excellent contribution to HammerDB.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post provides an introduction to the new feature added to HammerDB v4.9 by @krithikasatish\u00a0 and @JoshInnis to provide accelerated load performance for both SQL Server TPROC-C and TPROC-H schemas. This accelerated load is implemented using the BCP utility and is turned on or off with the &#8220;Use BCP Option&#8221; checkbox. With the default for &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.hammerdb.com\/blog\/uncategorized\/hammerdb-v4-9-new-feature-accelerate-sql-server-builds-with-bcp\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;HammerDB v4.9 New Feature: Accelerate SQL Server builds with BCP&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"ppma_author":[5],"class_list":["post-1545","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"authors":[{"term_id":5,"user_id":2,"is_guest":0,"slug":"hammerdb","display_name":"HammerDB","avatar_url":{"url":"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2018\/10\/logo-white.png","url2x":"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2018\/10\/logo-white.png"},"author_category":"","user_url":"http:\/\/www.hammerdb.com","last_name":"","first_name":"","job_title":"","description":""}],"_links":{"self":[{"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/posts\/1545","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/comments?post=1545"}],"version-history":[{"count":13,"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/posts\/1545\/revisions"}],"predecessor-version":[{"id":1566,"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/posts\/1545\/revisions\/1566"}],"wp:attachment":[{"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/media?parent=1545"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/categories?post=1545"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/tags?post=1545"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=1545"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}