8

I want to create a new database with a 200GB data file (.mdf) and 50GB log file (.ldf).

But it is very slow (it's about 15 minutes and still hasn't created). and it is very time consuming. Is that normal? if yes what does it do that takes time? can I enhance its creating speed?

I am using SQL Server 2008 R2, Windows Server 2008R2, 16GB RAM (which I limited that to 12GB in ssms) and Core i7 Cpu

marc_s
9,0626 gold badges46 silver badges52 bronze badges
asked Oct 7, 2013 at 19:52
1
  • 2
    For creation of a large database you're far more limited by disk I/O than anything else. If IFI is enabled (as per the answers) then you can skip initialising (zeroing out) the data file, but no matter what you have to initialise the log file. If you're using a typical consumer spinny disk that could take up to half an hour for the log file alone. Commented Oct 7, 2013 at 20:19

2 Answers 2

17

Unless you're using Instant File Initialization, SQL Server must zero out all sectors for the files. This is a very time consuming process, especially for 250 GB (data+log). In order to speed things up, enable this feature and then SQL Server will not zero out the space for the data files.

Please note, SQL Server will always zero out the log file, so you will still be limited by that. Another reference for log file initialization

Glorfindel
2,2095 gold badges19 silver badges26 bronze badges
answered Oct 7, 2013 at 20:01
4
  • what exactly happens on the hard disk when zero out all sectors and why SQL always zero out the log file? what is the advantage of doing that? Commented Oct 7, 2013 at 20:41
  • This is the process of erasing data on your disk. Basically, instant file initialization skips that. However, because of how the log file works internally, SQL Server must zero it out completely in order to use it. You can find more detail on it here. Commented Oct 7, 2013 at 20:47
  • @MehrdadKamelzadeh SQL server zeroing out file ONLY applies to Data files. Log files cannot be zero initialize. Refer to (sqlskills.com/blogs/paul/…). Also refer to How to tell if you have instant initialization enabled? (sqlskills.com/blogs/paul/…). Commented Oct 7, 2013 at 20:48
  • 1
    @Kin - Log files must be zero initialized, but with IFI you can skip zero-initializing the data files. Commented Oct 8, 2013 at 4:23
7

If you run secpol.msc what is the value for Local Polices, User Rights Assignment, Perform Volume Maintenance Tasks?

My assumption at this point is that the SQL Server service account doesn't have this right and so it zeroing out the mdf and the LDF. Can't get around the LDF being zeroed out but you can skip it for the MDF.

SecPol

Reference - http://timradney.com/2012/05/30/instant-file-initialization-for-sql-server-performance/

answered Oct 7, 2013 at 20:01

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.