August 26, 2013 at 9:06 am
Hello everyone,
I try to load data into a memOpt table (INSERT INTO ... SELECT ... FROM ...). The source table has a size about 1 Gb and 13 Mio Rows. During this load the LDF File grows to size of 350 GB (until the space if the disk is run out of space). The Server has about 110 GB Memory for the SQL Server reserved. The tempdB doesn't grow. The Bucket Size in the create statement has a size of 262144. The Hash key as 4 fields`(2 fields have the datatype int,1 has smallint, 1 has varchar(200). ) The disk for the datafiles has still space for the datafiles (incl. the hekaton files).
Can anyone guide how can I reduce the size of the ldf files during the load of the data ?
August 26, 2013 at 9:11 am
I would recommend breaking this into batches of 10k rows or so. A single insert with 13 million rows is going to kill your logs. This is one of those times that the dreaded cursor or while loop is actually going to increase your performance.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
August 26, 2013 at 11:18 am
Sean Lange (8/26/2013)
I would recommend breaking this into batches of 10k rows or so. A single insert with 13 million rows is going to kill your logs. This is one of those times that the dreaded cursor or while loop is actually going to increase your performance.
+1 because even actions on memory-optimized tables are logged unless you specify non-durable. http://technet.microsoft.com/en-us/library/dn133174(v=sql.120).aspx
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
October 14, 2013 at 4:57 am
Jack Corbett (8/26/2013)
Sean Lange (8/26/2013)
I would recommend breaking this into batches of 10k rows or so. A single insert with 13 million rows is going to kill your logs. This is one of those times that the dreaded cursor or while loop is actually going to increase your performance.+1 because even actions on memory-optimized tables are logged unless you specify non-durable. http://technet.microsoft.com/en-us/library/dn133174(v=sql.120).aspx
+2 With above suggestion iwould also suggest to change the recovery model of the database to simple if you can, if not take trasaction log backup in b/w the batches to free up the .ldf file. Some indexes can also be disabled during that load to avoid lots of updates (Indexes can be rebuild again after the load).
Overall Plan your activity accordingly 🙂
October 14, 2013 at 5:07 am
sql-noob (10/14/2013)
Jack Corbett (8/26/2013)
Sean Lange (8/26/2013)
I would recommend breaking this into batches of 10k rows or so. A single insert with 13 million rows is going to kill your logs. This is one of those times that the dreaded cursor or while loop is actually going to increase your performance.+1 because even actions on memory-optimized tables are logged unless you specify non-durable. http://technet.microsoft.com/en-us/library/dn133174(v=sql.120).aspx
+2 With above suggestion iwould also suggest to change the recovery model of the database to simple if you can, if not take trasaction log backup in b/w the batches to free up the .ldf file. Some indexes can also be disabled during that load to avoid lots of updates (Indexes can be rebuild again after the load).
Overall Plan your activity accordingly 🙂
Are you sure you can disable the index on an in-memory table?
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
October 14, 2013 at 5:32 am
My bad, the suggestion was for general ETL operations (Large one).
Forgot that it's hekaton.
October 14, 2013 at 5:59 am
Hello,
sorry I didn't mentioned, that I have already set the log model of the database to simple. Even with that configuration the Log growths in this way. I tried the suggestion with divide the data into smaller Batches. I managed that with creating a SSIS Package. In the properties of the 'data flow Task - OLE DB destitnation' it is possible to divide the load into Batches of 10K size. After that the copy of the data into the InMem Table works, without any unnormal growths of the log.
The exciting question will be, how SQL Server will handle this in a Environment, where it isn't possible to set the recovery model to simple (Mirrored Databases / Logshipped Databases). 😉 I hope in the RTM will be a improvent of that behavior.
October 23, 2013 at 12:08 am
The problem is fixed in the CTP 2, according this annoucement.
see:
October 23, 2013 at 8:08 am
Fecker Elmar (10/23/2013)
see:
You are still going to have log growth if you load a large amount of data in a single transaction unless you use non-durable table (schema only persisted) as all the inserts will still be logged for durability. I think the best practices for large ETL processes will still hold true for In-Memory OLTP as well.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
October 30, 2013 at 11:38 am
In production, you would load in batches, and run log backups during the load to keep the size manageable.
October 30, 2013 at 4:17 pm
If you really do have the DB in the SIMPLE Recovery Model, try SELECT/INTO or other "minimally logged" technique. Lookup "Minimally Logged" in Books Online for additional requirements for when you're not using SELECT/INTO.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply