{"id":536,"date":"2011-09-13T11:52:00","date_gmt":"2011-09-13T11:52:00","guid":{"rendered":"\/blogs\/paul\/post\/Initial-VLF-sequence-numbers-and-default-log-file-size.aspx"},"modified":"2013-01-27T09:20:08","modified_gmt":"2013-01-27T17:20:08","slug":"initial-vlf-sequence-numbers-and-default-log-file-size","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/paul\/initial-vlf-sequence-numbers-and-default-log-file-size\/","title":{"rendered":"Initial VLF sequence numbers and default log file size"},"content":{"rendered":"<p>\n<font face=\"verdana,geneva\" size=\"2\">We&#39;re teaching on-site with a financial client in New York for two weeks and in a session this morning on log file architecture I was asked why the VLF (virtual log file) sequence numbers in a new database don&#39;t start at one.<\/font>\n<\/p>\n<p>\n<font face=\"verdana,geneva\" size=\"2\">Here&#39;s an example:<\/font>\n<\/p>\n<blockquote>\n<p>\n\t<font face=\"courier new,courier\" size=\"2\">CREATE DATABASE foo;<br \/>\n\tGO<br \/>\n\tDBCC LOGINFO (&#39;foo&#39;);<br \/>\n\tGO<\/font>\n\t<\/p>\n<p>\n\t<font face=\"courier new,courier\" size=\"2\">FileId&nbsp; FileSize&nbsp; StartOffset FSeqNo Status&nbsp; Parity&nbsp; CreateLSN<br \/>\n\t&#8212;&#8212;- &#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8211; &#8212;&#8212; &#8212;&#8212;- &#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n\t2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 253952&nbsp;&nbsp;&nbsp; 8192&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 137&nbsp;&nbsp;&nbsp; 2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 64&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0<br \/>\n\t2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 253952&nbsp;&nbsp;&nbsp; 262144&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0<\/font>\n\t<\/p>\n<\/blockquote>\n<p>\n<font face=\"verdana,geneva\" size=\"2\">Why is the first sequence number (<font face=\"courier new,courier\">FSeqNo<\/font>)&nbsp;137 and not 1? (For an explanation of the various fields in the output of the undocumented <font face=\"courier new,courier\">DBCC LOGINFO<\/font>, see the post <\/font><a href=\"https:\/\/www.sqlskills.com\/blogs\/paul\/inside-the-storage-engine-more-on-the-circular-nature-of-the-log\/\"><font face=\"verdana,geneva\" size=\"2\">Inside the Storage Engine: More on the circular nature of the log<\/font><\/a><font face=\"verdana,geneva\" size=\"2\">.)<\/font>\n<\/p>\n<p>\n<font face=\"verdana,geneva\" size=\"2\">The answer is that it&#39;s one more than the highest VLF sequence number currently in the <font face=\"courier new,courier\">model<\/font> database. Let&#39;s see:<\/font>\n<\/p>\n<blockquote>\n<p>\n\t<font face=\"courier new,courier\" size=\"2\">DBCC LOGINFO (&#39;model&#39;);<br \/>\n\tGO<\/font>\n\t<\/p>\n<p>\n\t<font face=\"courier new,courier\" size=\"2\">FileId&nbsp; FileSize&nbsp; StartOffset FSeqNo Status&nbsp; Parity&nbsp; CreateLSN<br \/>\n\t&#8212;&#8212;- &#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8211; &#8212;&#8212; &#8212;&#8212;- &#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n\t2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 253952&nbsp;&nbsp;&nbsp; 8192&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 136&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 128&nbsp;&nbsp;&nbsp;&nbsp; 0<br \/>\n\t2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 262144&nbsp;&nbsp;&nbsp; 262144&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 135&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 128&nbsp;&nbsp;&nbsp;&nbsp; 0<\/font>\n\t<\/p>\n<\/blockquote>\n<p>\n<font face=\"verdana,geneva\" size=\"2\">The highest <font face=\"courier new,courier\">FSeqNo<\/font> in the output above is 136, which accounts for the&nbsp;137 in the new user database.<\/font>\n<\/p>\n<p>\n<font face=\"verdana,geneva\" size=\"2\">Now I&#39;ll prove it by increasing the sequence number in the <font face=\"courier new,courier\">model<\/font> database:<\/font>\n<\/p>\n<blockquote>\n<p>\n\t<font face=\"courier new,courier\" size=\"2\">USE model;<br \/>\n\tGO<br \/>\n\tCREATE TABLE BigRows (c1 INT IDENTITY, c2 CHAR (8000) DEFAULT &#39;a&#39;);<br \/>\n\tGO<br \/>\n\tINSERT INTO BigRows DEFAULT VALUES;<br \/>\n\tGO 50<br \/>\n\tDBCC LOGINFO;<br \/>\n\tGO<\/font>\n\t<\/p>\n<p>\n\t<font face=\"courier new,courier\" size=\"2\">FileId&nbsp; FileSize&nbsp; StartOffset FSeqNo Status&nbsp; Parity&nbsp; CreateLSN<br \/>\n\t&#8212;&#8212;- &#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8211; &#8212;&#8212; &#8212;&#8212;- &#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n\t2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 253952&nbsp;&nbsp;&nbsp; 8192&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 136&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 128&nbsp;&nbsp;&nbsp;&nbsp; 0<br \/>\n\t2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 262144&nbsp;&nbsp;&nbsp; 262144&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 137&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 128&nbsp;&nbsp;&nbsp;&nbsp; 0<\/font>\n\t<\/p>\n<\/blockquote>\n<p>\n<font face=\"verdana,geneva\" size=\"2\">And now I&#39;ll create another user database and the first VLF sequence number should be 138:<\/font>\n<\/p>\n<blockquote>\n<p>\n\t<font face=\"courier new,courier\" size=\"2\">CREATE DATABASE foo2;<br \/>\n\tGO<br \/>\n\tDBCC LOGINFO (&#39;foo2&#39;);<br \/>\n\tGO<\/font>\n\t<\/p>\n<p>\n\t<font face=\"courier new,courier\" size=\"2\">FileId&nbsp; FileSize&nbsp; StartOffset FSeqNo Status&nbsp; Parity&nbsp; CreateLSN<br \/>\n\t&#8212;&#8212;- &#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8211; &#8212;&#8212; &#8212;&#8212;- &#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n\t2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 253952&nbsp;&nbsp;&nbsp; 8192&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 138&nbsp;&nbsp;&nbsp; 2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 64&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0<br \/>\n\t2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 360448&nbsp;&nbsp;&nbsp; 262144&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0<\/font>\n\t<\/p>\n<\/blockquote>\n<p>\n<font face=\"verdana,geneva\" size=\"2\">And it is &#8211; proven!<\/font>\n<\/p>\n<p>\n<font face=\"verdana,geneva\" size=\"2\">The eagle-eyed among you may notice that the log file size of the database <font face=\"courier new,courier\">foo2<\/font> I just created is larger than the size of the <font face=\"courier new,courier\">foo<\/font> database I initially created. This is because the default log file size is the higher of 0.5MB or 25% of the sum of the data files created. In this case, the data file is copied from the <font face=\"courier new,courier\">model<\/font> database, and I made it larger when I created the <font face=\"courier new,courier\">BigRows<\/font> table, so the log file of the new database has to be slightly larger.<\/font>\n<\/p>\n<p>\n<font size=\"2\">One question that came up in the post comments &#8211; why is the highest VLF sequence number in my model database 136? No particular reason except I&#39;ve done a bunch of things in model which generated transaction log and so the VLF sequence numbers have increased. It&#39;s almost certain to be different in your SQL Server instances for that reason.<\/font>\n<\/p>\n<p>\n<font face=\"verdana,geneva\" size=\"2\">Next up tomorrow &#8211; results from the index count survey from last month.<\/font><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We&#39;re teaching on-site with a financial client in New York for two weeks and in a session this morning on log file architecture I was asked why the VLF (virtual log file) sequence numbers in a new database don&#39;t start at one. Here&#39;s an example: CREATE DATABASE foo; GO DBCC LOGINFO (&#39;foo&#39;); GO FileId&nbsp; FileSize&nbsp; [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[48,62,98],"tags":[],"class_list":["post-536","post","type-post","status-publish","format-standard","hentry","category-inside-the-storage-engine","category-on-disk-structures","category-transaction-log"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Initial VLF sequence numbers and default log file size - Paul S. Randal<\/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.sqlskills.com\/blogs\/paul\/initial-vlf-sequence-numbers-and-default-log-file-size\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Initial VLF sequence numbers and default log file size - Paul S. Randal\" \/>\n<meta property=\"og:description\" content=\"We&#039;re teaching on-site with a financial client in New York for two weeks and in a session this morning on log file architecture I was asked why the VLF (virtual log file) sequence numbers in a new database don&#039;t start at one. Here&#039;s an example: CREATE DATABASE foo; GO DBCC LOGINFO (&#039;foo&#039;); GO FileId&nbsp; FileSize&nbsp; [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/paul\/initial-vlf-sequence-numbers-and-default-log-file-size\/\" \/>\n<meta property=\"og:site_name\" content=\"Paul S. Randal\" \/>\n<meta property=\"article:published_time\" content=\"2011-09-13T11:52:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2013-01-27T17:20:08+00:00\" \/>\n<meta name=\"author\" content=\"Paul Randal\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Paul Randal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/initial-vlf-sequence-numbers-and-default-log-file-size\/\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/initial-vlf-sequence-numbers-and-default-log-file-size\/\",\"name\":\"Initial VLF sequence numbers and default log file size - Paul S. Randal\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#website\"},\"datePublished\":\"2011-09-13T11:52:00+00:00\",\"dateModified\":\"2013-01-27T17:20:08+00:00\",\"author\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/initial-vlf-sequence-numbers-and-default-log-file-size\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlskills.com\/blogs\/paul\/initial-vlf-sequence-numbers-and-default-log-file-size\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/initial-vlf-sequence-numbers-and-default-log-file-size\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Initial VLF sequence numbers and default log file size\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#website\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/\",\"name\":\"Paul S. Randal\",\"description\":\"In Recovery...\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce\",\"name\":\"Paul Randal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g\",\"caption\":\"Paul Randal\"},\"sameAs\":[\"http:\/\/3.209.169.194\/blogs\/paul\"],\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/author\/paul\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Initial VLF sequence numbers and default log file size - Paul S. Randal","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.sqlskills.com\/blogs\/paul\/initial-vlf-sequence-numbers-and-default-log-file-size\/","og_locale":"en_US","og_type":"article","og_title":"Initial VLF sequence numbers and default log file size - Paul S. Randal","og_description":"We&#39;re teaching on-site with a financial client in New York for two weeks and in a session this morning on log file architecture I was asked why the VLF (virtual log file) sequence numbers in a new database don&#39;t start at one. Here&#39;s an example: CREATE DATABASE foo; GO DBCC LOGINFO (&#39;foo&#39;); GO FileId&nbsp; FileSize&nbsp; [&hellip;]","og_url":"https:\/\/www.sqlskills.com\/blogs\/paul\/initial-vlf-sequence-numbers-and-default-log-file-size\/","og_site_name":"Paul S. Randal","article_published_time":"2011-09-13T11:52:00+00:00","article_modified_time":"2013-01-27T17:20:08+00:00","author":"Paul Randal","twitter_misc":{"Written by":"Paul Randal","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/initial-vlf-sequence-numbers-and-default-log-file-size\/","url":"https:\/\/www.sqlskills.com\/blogs\/paul\/initial-vlf-sequence-numbers-and-default-log-file-size\/","name":"Initial VLF sequence numbers and default log file size - Paul S. Randal","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#website"},"datePublished":"2011-09-13T11:52:00+00:00","dateModified":"2013-01-27T17:20:08+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/initial-vlf-sequence-numbers-and-default-log-file-size\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/paul\/initial-vlf-sequence-numbers-and-default-log-file-size\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/initial-vlf-sequence-numbers-and-default-log-file-size\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/paul\/"},{"@type":"ListItem","position":2,"name":"Initial VLF sequence numbers and default log file size"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#website","url":"https:\/\/www.sqlskills.com\/blogs\/paul\/","name":"Paul S. Randal","description":"In Recovery...","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlskills.com\/blogs\/paul\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce","name":"Paul Randal","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g","caption":"Paul Randal"},"sameAs":["http:\/\/3.209.169.194\/blogs\/paul"],"url":"https:\/\/www.sqlskills.com\/blogs\/paul\/author\/paul\/"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts\/536","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/comments?post=536"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts\/536\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/media?parent=536"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/categories?post=536"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/tags?post=536"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}