<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://sqlblog.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Geek City: Where are LOBs stored?</title><link>http://sqlblog.com/blogs/kalen_delaney/archive/2011/06/26/where-are-lobs-stored.aspx</link><description>When researching a question from one of the students in my class last week, I was reading the documentation for CREATE TABLE about storing LOB columns at http://msdn.microsoft.com/en-us/library/ms174979.aspx . For this discussion LOB columns includes</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>re: Geek City: Where are LOBs stored?</title><link>http://sqlblog.com/blogs/kalen_delaney/archive/2011/06/26/where-are-lobs-stored.aspx#36491</link><pubDate>Mon, 27 Jun 2011 18:14:34 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:36491</guid><dc:creator>Wes Clark</dc:creator><description>&lt;p&gt;What you have proved is the actual behavior is how I instinctually understood what the documentation was saying, but as you have pointed out, default has a specific meaning, and the documentation is wrong. &amp;nbsp;Have you filed a bug on that?&lt;/p&gt;
&lt;p&gt;Did you try specifying &amp;quot;default&amp;quot; to see where the LOB data went then? &lt;/p&gt;
</description></item><item><title>re: Geek City: Where are LOBs stored?</title><link>http://sqlblog.com/blogs/kalen_delaney/archive/2011/06/26/where-are-lobs-stored.aspx#36494</link><pubDate>Mon, 27 Jun 2011 18:32:29 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:36494</guid><dc:creator>Kalen Delaney</dc:creator><description>&lt;p&gt;Hi Wes... &lt;/p&gt;
&lt;p&gt;Are you saying you understood &amp;quot;default&amp;quot; to mean &amp;quot;the FG where the rest of the table was going? &lt;/p&gt;
&lt;p&gt;I showed you the code I ran. I would guess that explicitly saying &amp;quot;default&amp;quot; would refer to the default fg, in this case PRIMARY. &lt;/p&gt;
&lt;p&gt;You're free to take my good and modify one of the CREATE TABLE commands to specify &amp;quot;default&amp;quot; for the TEXTIMAGE_ON filegroup. Let us know what you get!&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;Kalen&lt;/p&gt;
</description></item><item><title>re: Geek City: Where are LOBs stored?</title><link>http://sqlblog.com/blogs/kalen_delaney/archive/2011/06/26/where-are-lobs-stored.aspx#36522</link><pubDate>Tue, 28 Jun 2011 19:25:55 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:36522</guid><dc:creator>Stuart Cowen</dc:creator><description>&lt;p&gt;Great article and example code. I actually ran this step-by-step in my 180-day eval SS2K8R2 instance and realized the same results. This post is way over my current skill-level, but I was able to track with you and it seemed to make sense. I appreciate it :)&lt;/p&gt;
</description></item><item><title>re: Geek City: Where are LOBs stored?</title><link>http://sqlblog.com/blogs/kalen_delaney/archive/2011/06/26/where-are-lobs-stored.aspx#36531</link><pubDate>Tue, 28 Jun 2011 21:52:48 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:36531</guid><dc:creator>Kalen Delaney</dc:creator><description>&lt;p&gt;Thanks for your feedback, Stuart! &amp;nbsp;This is a great way to start getting a feel for what is waiting for you as you start getting and deeper and deeper in!&lt;/p&gt;
&lt;p&gt;~Kalen&lt;/p&gt;
</description></item><item><title>re: Geek City: Where are LOBs stored?</title><link>http://sqlblog.com/blogs/kalen_delaney/archive/2011/06/26/where-are-lobs-stored.aspx#36545</link><pubDate>Thu, 30 Jun 2011 00:05:05 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:36545</guid><dc:creator>Greg Linwood</dc:creator><description>&lt;p&gt;nice article Kalen, thx. I was having a discussion about this with a customer just a few days ago so I can now refer them here for further reading :)&lt;/p&gt;
</description></item><item><title>re: Geek City: Where are LOBs stored?</title><link>http://sqlblog.com/blogs/kalen_delaney/archive/2011/06/26/where-are-lobs-stored.aspx#36546</link><pubDate>Thu, 30 Jun 2011 00:15:06 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:36546</guid><dc:creator>Kalen Delaney</dc:creator><description>&lt;p&gt;Hi Greg!&lt;/p&gt;
&lt;p&gt;I'm glad it was useful.&lt;/p&gt;
&lt;p&gt;:-)&lt;/p&gt;
</description></item><item><title>re: Geek City: Where are LOBs stored?</title><link>http://sqlblog.com/blogs/kalen_delaney/archive/2011/06/26/where-are-lobs-stored.aspx#36639</link><pubDate>Tue, 05 Jul 2011 14:12:16 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:36639</guid><dc:creator>Dale</dc:creator><description>&lt;p&gt;I added the following code to the above:&lt;/p&gt;
&lt;p&gt;IF EXISTS (SELECT 1 FROM sys.tables WHERE name = 'bigrows4')&lt;/p&gt;
&lt;p&gt;DROP TABLE bigrows4;&lt;/p&gt;
&lt;p&gt;GO&lt;/p&gt;
&lt;p&gt;CREATE TABLE bigrows4 &lt;/p&gt;
&lt;p&gt;(a char(1000),&lt;/p&gt;
&lt;p&gt;b varchar(8000),&lt;/p&gt;
&lt;p&gt;c text )&lt;/p&gt;
&lt;p&gt;ON FG1 TEXTIMAGE_ON 'default';&lt;/p&gt;
&lt;p&gt;GO&lt;/p&gt;
&lt;p&gt;INSERT INTO bigrows4 &lt;/p&gt;
&lt;p&gt;SELECT REPLICATE('a', 1000), REPLICATE('b', 1000),&lt;/p&gt;
&lt;p&gt;REPLICATE('c', 50);&lt;/p&gt;
&lt;p&gt;GO&lt;/p&gt;
&lt;p&gt;SELECT OBJECT_NAME(object_id) as object_name, FILEGROUP_NAME(data_space_id) as FG_name, type_desc &lt;/p&gt;
&lt;p&gt;FROM sys.partitions p&lt;/p&gt;
&lt;p&gt;JOIN sys.allocation_units a&lt;/p&gt;
&lt;p&gt;on p.partition_id = a.container_id&lt;/p&gt;
&lt;p&gt;WHERE OBJECT_NAME(object_id) like 'bigrows%';&lt;/p&gt;
&lt;p&gt;GO&lt;/p&gt;
&lt;p&gt;--------------------------&lt;/p&gt;
&lt;p&gt;The results I got back were:&lt;/p&gt;
&lt;p&gt;object_name	FG_name	type_desc&lt;/p&gt;
&lt;p&gt;bigrows	PRIMARY	IN_ROW_DATA&lt;/p&gt;
&lt;p&gt;bigrows	PRIMARY	LOB_DATA&lt;/p&gt;
&lt;p&gt;bigrows	PRIMARY	ROW_OVERFLOW_DATA&lt;/p&gt;
&lt;p&gt;bigrows2	FG1	IN_ROW_DATA&lt;/p&gt;
&lt;p&gt;bigrows2	FG1	LOB_DATA&lt;/p&gt;
&lt;p&gt;bigrows2	FG1	ROW_OVERFLOW_DATA&lt;/p&gt;
&lt;p&gt;bigrows3	FG1	IN_ROW_DATA&lt;/p&gt;
&lt;p&gt;bigrows3	FG2	LOB_DATA&lt;/p&gt;
&lt;p&gt;bigrows3	FG1	ROW_OVERFLOW_DATA&lt;/p&gt;
&lt;p&gt;bigrows4	FG1	IN_ROW_DATA&lt;/p&gt;
&lt;p&gt;bigrows4	PRIMARY	LOB_DATA&lt;/p&gt;
&lt;p&gt;bigrows4	FG1	ROW_OVERFLOW_DATA&lt;/p&gt;
&lt;p&gt;--------------------------------&lt;/p&gt;
&lt;p&gt;So it looks like if you specify TEXTIMAGE_ON 'default', it goes to the PRIMARY filegroup.&lt;/p&gt;
</description></item><item><title>re: Geek City: Where are LOBs stored?</title><link>http://sqlblog.com/blogs/kalen_delaney/archive/2011/06/26/where-are-lobs-stored.aspx#36656</link><pubDate>Tue, 05 Jul 2011 19:44:21 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:36656</guid><dc:creator>Kalen Delaney</dc:creator><description>&lt;p&gt;Thanks, Dale. In this script it went to the PRIMARY filegroup because the PRIMARY FG is the default FG, but remember that you can change which FG is default. So 'default' actually means a specific FG, whichever one was declared default, and it does not mean 'the FG where the rest of the data is'.&lt;/p&gt;
&lt;p&gt;~Kalen &lt;/p&gt;
</description></item><item><title>re: Geek City: Where are LOBs stored?</title><link>http://sqlblog.com/blogs/kalen_delaney/archive/2011/06/26/where-are-lobs-stored.aspx#36853</link><pubDate>Wed, 13 Jul 2011 00:19:38 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:36853</guid><dc:creator>Matic Zeljko</dc:creator><description>&lt;p&gt;If you create table without LOB and after some time add LOB column you should drop and recreate table to be able to assigne textimage_on option. &lt;/p&gt;
&lt;p&gt;It's more complicated if you use table in merge replication and do smoething of following:&lt;/p&gt;
&lt;p&gt;- on creation of table you not specify textimage_on and add after some time add it to replication &lt;/p&gt;
&lt;p&gt;- in time of making table as part of replication you not have LOB (If you don't have LOB textimage_on can't be specified (or is ignored and changed in data filegroup)) but after some time you add LOB to table through replication. &lt;/p&gt;
&lt;p&gt;In both case you cant't change or add textimage_on option. &lt;/p&gt;
</description></item><item><title>re: Geek City: Where are LOBs stored?</title><link>http://sqlblog.com/blogs/kalen_delaney/archive/2011/06/26/where-are-lobs-stored.aspx#36855</link><pubDate>Wed, 13 Jul 2011 01:20:34 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:36855</guid><dc:creator>Kalen Delaney</dc:creator><description>&lt;p&gt;Hi Matic&lt;/p&gt;
&lt;p&gt;Thanks for the additional data points!&lt;/p&gt;
&lt;p&gt;~Kalen&lt;/p&gt;
</description></item><item><title>re: Geek City: Where are LOBs stored?</title><link>http://sqlblog.com/blogs/kalen_delaney/archive/2011/06/26/where-are-lobs-stored.aspx#40916</link><pubDate>Mon, 09 Jan 2012 21:03:39 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:40916</guid><dc:creator>Chirag Shah</dc:creator><description>&lt;p&gt;I had the same question when creating a table (found your blog post)&lt;/p&gt;
&lt;p&gt;It appears to me that SQL 2000 BOL documentation is much cleaner. &lt;/p&gt;
&lt;p&gt;from &lt;a rel="nofollow" target="_new" href="http://msdn.microsoft.com/en-us/library/aa258255"&gt;http://msdn.microsoft.com/en-us/library/aa258255&lt;/a&gt;(v=sql.80).aspx&lt;/p&gt;
&lt;p&gt;If TEXTIMAGE_ON is not specified, the text, ntext, and image columns are stored in the same filegroup as the table&lt;/p&gt;
</description></item><item><title>re: Geek City: Where are LOBs stored?</title><link>http://sqlblog.com/blogs/kalen_delaney/archive/2011/06/26/where-are-lobs-stored.aspx#40924</link><pubDate>Tue, 10 Jan 2012 01:06:42 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:40924</guid><dc:creator>Kalen Delaney</dc:creator><description>&lt;p&gt;Hi Chirag&lt;/p&gt;
&lt;p&gt;They had to rewrite the docs for SQL 2005, to add info about varchar(MAX), and partitions, so they seemed to have made it more complicated that it needed to be.&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;
&lt;p&gt;Kalen&lt;/p&gt;
</description></item><item><title>re: Geek City: Where are LOBs stored?</title><link>http://sqlblog.com/blogs/kalen_delaney/archive/2011/06/26/where-are-lobs-stored.aspx#44959</link><pubDate>Fri, 31 Aug 2012 15:19:02 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:44959</guid><dc:creator>Yuval</dc:creator><description>&lt;p&gt;I want put VARBINARY(MAX) on a filegroup. when i run &lt;/p&gt;
&lt;p&gt;SELECT [type],type_desc,FILEGROUP_NAME( data_space_id) FGname,total_pages,used_pages,data_pages&lt;/p&gt;
&lt;p&gt; &amp;nbsp;FROM sys.allocation_units A&lt;/p&gt;
&lt;p&gt; &amp;nbsp;INNER JOIN sys.partitions p&lt;/p&gt;
&lt;p&gt; &amp;nbsp;ON P.partition_id = A.container_id&lt;/p&gt;
&lt;p&gt; &amp;nbsp;WHERE &amp;nbsp;P.object_id = OBJECT_ID(N'DMS_Message')&lt;/p&gt;
&lt;p&gt;I got:&lt;/p&gt;
&lt;p&gt;type	type_desc	FGname	total_pages	used_pages	data_pages&lt;/p&gt;
&lt;p&gt;1	IN_ROW_DATA	PRIMARY	7	7	5&lt;/p&gt;
&lt;p&gt;2	LOB_DATA	FG_Big_Binary	0	0	0&lt;/p&gt;
&lt;p&gt;3	ROW_OVERFLOW_DATA	PRIMARY	0	0	0&lt;/p&gt;
&lt;p&gt;1	IN_ROW_DATA	PRIMARY	2	2	1&lt;/p&gt;
&lt;p&gt;Are pages of LOB_DATA empty? Why?&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
</description></item><item><title>re: Geek City: Where are LOBs stored?</title><link>http://sqlblog.com/blogs/kalen_delaney/archive/2011/06/26/where-are-lobs-stored.aspx#44962</link><pubDate>Fri, 31 Aug 2012 16:50:28 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:44962</guid><dc:creator>Kalen Delaney</dc:creator><description>&lt;p&gt;Hi Yuval&lt;/p&gt;
&lt;p&gt;What data did you put in the table? If varbinary(max) is less than 8000 bytes, it can go in the in_row_data allocation unit with the rest of the table data. &lt;/p&gt;
&lt;p&gt;~Kalen&lt;/p&gt;
</description></item><item><title>re: Geek City: Where are LOBs stored?</title><link>http://sqlblog.com/blogs/kalen_delaney/archive/2011/06/26/where-are-lobs-stored.aspx#44968</link><pubDate>Sat, 01 Sep 2012 17:50:22 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:44968</guid><dc:creator>Yuval</dc:creator><description>&lt;p&gt;Thanks Kalen,&lt;/p&gt;
&lt;p&gt;My current state is according your suggestion and I experience performance problem, when multi threads insert to the table, there are latch waits.&lt;/p&gt;
&lt;p&gt;I want to move the varbinary column to dedicated filegroup and gain both: in the data-row page, the writes will be faster and the big data will be written to a separate page for each record (will it?) without blocking other threads.&lt;/p&gt;
&lt;p&gt;When implementing, as I wrote before, it seems the LOB_DATA pages are not used. Is it true? Why?&lt;/p&gt;
&lt;p&gt;Thanks again,&lt;/p&gt;
&lt;p&gt;Yuval&lt;/p&gt;
</description></item><item><title>re: Geek City: Where are LOBs stored?</title><link>http://sqlblog.com/blogs/kalen_delaney/archive/2011/06/26/where-are-lobs-stored.aspx#44970</link><pubDate>Sat, 01 Sep 2012 19:59:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:44970</guid><dc:creator>Yuval</dc:creator><description>&lt;p&gt;Update:&lt;/p&gt;
&lt;p&gt;When I used IMAGE instead of VARBINARY(MAX) I got:&lt;/p&gt;
&lt;p&gt;rows	type	type_desc	FGname	total_pages	used_pages	data_pages&lt;/p&gt;
&lt;p&gt;10	1	IN_ROW_DATA	PRIMARY	2	2	1&lt;/p&gt;
&lt;p&gt;10	2	LOB_DATA	FG_Big_Binary	17	11	0&lt;/p&gt;
&lt;p&gt;So, how can I force VARBINARY(MAX) to be applied on the LOB filegroup?&lt;/p&gt;
&lt;p&gt;or, should i use IMAGE instead of VARBINARY(MAX)?&lt;/p&gt;
&lt;p&gt;Yuval&lt;/p&gt;
</description></item><item><title>re: Geek City: Where are LOBs stored?</title><link>http://sqlblog.com/blogs/kalen_delaney/archive/2011/06/26/where-are-lobs-stored.aspx#44971</link><pubDate>Sun, 02 Sep 2012 01:36:16 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:44971</guid><dc:creator>Kalen Delaney</dc:creator><description>&lt;p&gt;Yuval&lt;/p&gt;
&lt;p&gt;You still haven't answered my question and told me what data you are loading in, and how big it is. As I said, if it is less than 8K, varbinary(max) will store it in the row, not in a LOB allocation unit. Since you say that if you store it as IMAGE instead, and that uses the LOB allocation_unit, I would guess that it is less than 8K, because IMAGE is always stored outside the row by default. &lt;/p&gt;
&lt;p&gt;Since IMAGE is going away in the next version of SQL Server, I suggest that you don't use it. If you want your varbinary(MAX) to be always stored outside the row, so you can place it on its own filegroup, take a look at sp_tableoption. You can run a command like this, but please check the docs for full details:&lt;/p&gt;
&lt;p&gt;EXEC sp_tableoption 'your_table_name', 'large value types out of row', 1&lt;/p&gt;
&lt;p&gt;I hope this helps&lt;/p&gt;
&lt;p&gt;~Kalen&lt;/p&gt;
</description></item><item><title>re: Geek City: Where are LOBs stored?</title><link>http://sqlblog.com/blogs/kalen_delaney/archive/2011/06/26/where-are-lobs-stored.aspx#44978</link><pubDate>Sun, 02 Sep 2012 21:07:18 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:44978</guid><dc:creator>Yuval</dc:creator><description>&lt;p&gt;Thanks a lot,&lt;/p&gt;
&lt;p&gt;It worked, data was allocated at LOB_DATA filegroup pages.&lt;/p&gt;
&lt;p&gt;Still, there were lass pages than rows (yes, most of LOB's are less than 8KB). &lt;/p&gt;
&lt;p&gt;What is the order rows are written to LOB_DATA pages?&lt;/p&gt;
&lt;p&gt;Will a thread interfere inserting's of others? (Latch wait) &lt;/p&gt;
&lt;p&gt;yuval&lt;/p&gt;
</description></item><item><title>re: Geek City: Where are LOBs stored?</title><link>http://sqlblog.com/blogs/kalen_delaney/archive/2011/06/26/where-are-lobs-stored.aspx#45568</link><pubDate>Mon, 15 Oct 2012 07:52:43 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:45568</guid><dc:creator>Yuval</dc:creator><description>&lt;p&gt;Well,&lt;/p&gt;
&lt;p&gt;I had the opportunity to test the solution of moving big-data-column to dedicated file-group (using TEXTIMAGE_ON clause). &lt;/p&gt;
&lt;p&gt;The solution is working, there were no latch waits and total process duration was reduced by 50%.&lt;/p&gt;
&lt;p&gt;Thanks again,&lt;/p&gt;
&lt;p&gt;Yuval&lt;/p&gt;
</description></item></channel></rss>