concept log in category sql

This is an excerpt from Manning's book SQL Server MVP Deep Dives Vol. 2.
It’s the weekend, and you’re looking forward to catching up with friends and family before going back to the office on Monday morning. Unfortunately, your mobile phone wakes you at 3:30 a.m. on Saturday. The on-call DBA (who’s new to the organization) is on the other end frantically asking you what she should do—all the important databases are offline. This means that all the processing done in the early hours of the morning that must be completed before other time-sensitive work can be done may be impacted if the databases can’t come online quickly. Because it only appears to be a database problem at the moment, the spotlight is on the DBAs. Because the on-call DBA wasn’t equipped to deal with this scenario, you get up and remotely log into the environment to do some initial troubleshooting. After doing a bit of investigation, you notice errors in the logs that are indicative of a storage problem. All systems with local storage are fine, but any server configured with SQL Server and connected to that particular SAN has been affected.
Msg 3159, Level 16, State 1, Line 1 The tail of the log for the database "dbname" has not been backed up. Use BACKUP LOG WITH NORECOVERY to backup the log if it contains work you do not want to lose. Use the WITH REPLACE or WITH STOPAT clause of the RESTORE statement to just overwrite the contents of the log. Msg 3013, Level 16, State 1, Line 1 RESTORE DATABASE is terminating abnormally.
As with most recommendations, these numbers are generic and may not fit your particular environment. Ideally, in a busy OLTP system, I like to see five ms latency or less for both reads and writes for my transaction log. On less busy systems, a higher latency may not be a problem. But the higher the latency, the higher the potential for transaction log I/O performance issues. When I check out a server, and if the read and write latency is very good to excellent, I’m generally satisfied. If they’re higher than 10 ms, I start checking my options for boosting transaction log I/O throughput.

This is an excerpt from Manning's book SQL Server MVP Deep Dives.
To show you how the recovery model and the TABLOCK hint affect the size of the log, we will create six databases: two databases per recovery level. For each recovery level, we will run the bulk insert with and without the TABLOCK hint.
Listing 4. Creating a user database
#createdatabase.ps1 #Creates a new database using our specifications param ( [string]$srvname='MyServer\MyInstance', [string]$dbname='MyAppDB', [int]$datsize=25, [int]$maxsize=100, [int]$logsize=10 ) # Load SMO assembly, and if we're running SQL 2008 DLLs load the SMOExtended and SQLWMIManagement libraries $v = [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') $p = $v.FullName.Split(',') $p1 = $p[1].Split('=') $p2 = $p1[1].Split('.') if ($p2[0] -ne '9') { [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMOExtended') | out-null [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SQLWMIManagement') | out-null } $srv = new-object ('Microsoft.SqlServer.Management.Smo.Server') $srvname # Instantiate the database object and add the filegroups $db = new-object ('Microsoft.SqlServer.Management.Smo.Database') ($srv, $dbname) $sysfg = new-object ('Microsoft.SqlServer.Management.Smo.FileGroup') ($db, 'PRIMARY') $db.FileGroups.Add($sysfg) $appfg = new-object ('Microsoft.SqlServer.Management.Smo.FileGroup') ($db, 'AppFG') $db.FileGroups.Add($appfg) # Create the file for the system tables $dbdsysfile = new-object ('Microsoft.SqlServer.Management.Smo.DataFile') ($sysfg, 'MyAppDB_SysData') $sysfg.Files.Add($dbdsysfile) $dbdsysfile.FileName = $srv.Information.MasterDBPath + '\MyAppDB_SysData.mdf' $dbdsysfile.Size = [double](5.0 * 1024.0) $dbdsysfile.GrowthType = 'KB' $dbdsysfile.Growth = [double](5.0 * 1024.0) $dbdsysfile.IsPrimaryFile = 'True' # Create the file for the Application tables $dbdappfile = new-object ('Microsoft.SqlServer.Management.Smo.DataFile') ($appfg, 'MyAppDB_AppData') $appfg.Files.Add($dbdappfile) $dbdappfile.FileName = $srv.Information.MasterDBPath + '\MyAppDB_AppData.ndf' $dbdappfile.Size = [double](25.0 * 1024.0) $dbdappfile.GrowthType = 'KB' $dbdappfile.Growth = [double]($datsize * 1024.0) $dbdappfile.MaxSize = [double]($maxsize * 1024.0) # Create the file for the log $dblfile = new-object ('Microsoft.SqlServer.Management.Smo.LogFile') ($db, 'MyAppDB_Log') $db.LogFiles.Add($dblfile) $dblfile.FileName = $srv.Information.MasterDBLogPath + '\MyAppDB_Log.ldf' $dblfile.Size = [double]($logsize * 1024.0) $dblfile.GrowthType = 'KB' $dblfile.Growth = [double]($logsize * 1024.0) # Create the database $db.Create() # Set the default filegroup to AppFG $appfg = $db.FileGroups['AppFG'] $appfg.IsDefault = $true $appfg.Alter() $db.Alter()
Although Microsoft has continued to implement new and innovative means of troubleshooting problems and monitoring performance, only SQL Profiler and Windows Performance Monitor are available on every version of SQL Server since SQL Server 7.0. To get the maximum value from the two tools, be sure to follow the simple best practices, such as monitoring a problem SQL Server from a different workstation. When you’ve collected logs from both PerfMon and Profiler, you can load both log files into SQL Profiler where you can review the correlated information from both data sets. Application performance in a Microsoft SQL Server environment is directly related to the efficiency of the SQL statements involved. By reviewing the bottlenecks in SQL Server resources as revealed by PerfMon, and correlating those bottlenecks with Profiler data, you can see exactly which SQL statements have hindered performance. Such statements are obvious tuning targets.