Create Database and LCK_M_S We are experiencing issues when creating a database in the SSMS GUI in that sometimes it times out complaining that it could not get an exclusive lock on the Model database.  Other times the database gets created but does seem to be taking a long time.

I have also added the Service Account to the Perform Volume Maintenance local security policy.

This is a brand new clustered SQL server with no other processes running on it at the moment.

I have queried the wait types and the largest is LCK_M_S

I have queried sys.dm_tran_locks during the time when it does get created and can see two locks



Is this correct, does anyone have any advice why the DB creation may be taking so long?

Same issues when using code, being the following:

CREATE DATABASE [TestTom]
 CONTAINMENT = NONE
 ON  PRIMARY 
( NAME = N'TestTom', FILENAME = N'G:\MSSQL11.MSSQLSERVER\MSSQL\DATA\TestTom.mdf' , SIZE = 1048576KB , FILEGROWTH = 1048576KB )
 LOG ON 
( NAME = N'TestTom_log', FILENAME = N'F:\MSSQL11.MSSQLSERVER\MSSQL\Data\TestTom_log.ldf' , SIZE = 1048576KB , FILEGROWTH = 1048576KB )
GO
ALTER DATABASE [TestTom] SET COMPATIBILITY_LEVEL = 110
GO
ALTER DATABASE [TestTom] SET ANSI_NULL_DEFAULT OFF 
GO
ALTER DATABASE [TestTom] SET ANSI_NULLS OFF 
GO
ALTER DATABASE [TestTom] SET ANSI_PADDING OFF 
GO
ALTER DATABASE [TestTom] SET ANSI_WARNINGS OFF 
GO
ALTER DATABASE [TestTom] SET ARITHABORT OFF 
GO
ALTER DATABASE [TestTom] SET AUTO_CLOSE OFF 
GO
ALTER DATABASE [TestTom] SET AUTO_CREATE_STATISTICS ON 
GO
ALTER DATABASE [TestTom] SET AUTO_SHRINK OFF 
GO
ALTER DATABASE [TestTom] SET AUTO_UPDATE_STATISTICS ON 
GO
ALTER DATABASE [TestTom] SET CURSOR_CLOSE_ON_COMMIT OFF 
GO
ALTER DATABASE [TestTom] SET CURSOR_DEFAULT  GLOBAL 
GO
ALTER DATABASE [TestTom] SET CONCAT_NULL_YIELDS_NULL OFF 
GO
ALTER DATABASE [TestTom] SET NUMERIC_ROUNDABORT OFF 
GO
ALTER DATABASE [TestTom] SET QUOTED_IDENTIFIER OFF 
GO
ALTER DATABASE [TestTom] SET RECURSIVE_TRIGGERS OFF 
GO
ALTER DATABASE [TestTom] SET  DISABLE_BROKER 
GO
ALTER DATABASE [TestTom] SET AUTO_UPDATE_STATISTICS_ASYNC OFF 
GO
ALTER DATABASE [TestTom] SET DATE_CORRELATION_OPTIMIZATION OFF 
GO
ALTER DATABASE [TestTom] SET PARAMETERIZATION SIMPLE 
GO
ALTER DATABASE [TestTom] SET READ_COMMITTED_SNAPSHOT OFF 
GO
ALTER DATABASE [TestTom] SET  READ_WRITE 
GO
ALTER DATABASE [TestTom] SET RECOVERY SIMPLE 
GO
ALTER DATABASE [TestTom] SET  MULTI_USER 
GO
ALTER DATABASE [TestTom] SET PAGE_VERIFY CHECKSUM  
GO
ALTER DATABASE [TestTom] SET TARGET_RECOVERY_TIME = 0 SECONDS 
GO
USE [TestTom]
GO
IF NOT EXISTS (SELECT name FROM sys.filegroups WHERE is_default=1 AND name = N'PRIMARY') ALTER DATABASE [TestTom] MODIFY FILEGROUP [PRIMARY] DEFAULT
GO
If you see below segment of the code

CREATE DATABASE [TestTom]
 CONTAINMENT = NONE
 ON  PRIMARY 
( NAME = N'TestTom', FILENAME = N'G:\MSSQL11.MSSQLSERVER\MSSQL\DATA\TestTom.mdf' , SIZE = 1048576KB , FILEGROWTH = 1048576KB )
 LOG ON 
( NAME = N'TestTom_log', FILENAME = N'F:\MSSQL11.MSSQLSERVER\MSSQL\Data\TestTom_log.ldf' , SIZE = 1048576KB , FILEGROWTH = 1048576KB )
GO


The size which you are pre-allocating is 1048576KB which is approx 1G.

The same is with Log file 1048576KB which is 1G.

Can you alter your script and put it to few MB's and see if you again get the locking. You can later run alter database modify file script to increase size. This is something I have witnessed to telling you. This is not a definitive answer but I am sure it will reduce the creation time which exactly is your problem. 

Did you also noted if any process was blocking the table creation script. 

Plus first run create database script and then the alter database commands.