Beruflich Dokumente
Kultur Dokumente
Twitter: @christianbolton
christian@coeo.com
http://sqlblogcasts.com/blogs/christian
01/05/2012
Every Edition can restore a compressed backup Calculate your compression ratio with
SELECT backup_size/compressed_backup_size FROM msdb..backupset;
01/05/2012
Helps to prevent plan cache bloat Use of Ad-Hoc T-SQL can make plans difficult to re-use Plan cache fills up with many single use plans
Can cause internal memory pressure as memory is taken away from the data cache
01/05/2012
Only a small execution plan stub is cached on first use The full plan is only cached if its used more than once
sys.dm_exec_cached_plans
01/05/2012
SELECT COUNT(*) AS 'Single Use Plans', SUM(CAST(size_in_bytes AS BIGINT)/1024/1024) AS 'Total Size (MB)' FROM sys.dm_exec_cached_plans WHERE usecounts = 1
01/05/2012
Legacy, deprecated setting SQL Servers threads are started in high priority Can prevent non-SQL Server threads from running
Do not use!
01/05/2012
Instant File Initialization The good bits Uses NTFS technology introduced in Win 2003 Skips initializing files with zero Data file creation and expansion VERY fast
Large databases created within seconds Manually expand data files by large amounts Set large data file autogrow amounts Restores will be quicker with large freespace
01/05/2012
01/05/2012
When is it enabled? SQL Server service account is a Windows administrator SQL Server is running under LocalSystem SQL Server service account is a local or domain user with the Perform Volume Maintenance Tasks advanced user right
Use gpedit.msc or Group Policy
01/05/2012
How can you be sure SQL Server has permission? whoami /priv
10
01/05/2012
Default Database autogrow values SQL Server autogrows database files by default to keep databases running 1MB by default for data files 10% for transaction log files These defaults are inherited from the Model database
11
01/05/2012
Production databases are usually larger than a few MB If they need to grow then 1MB usually isnt enough for very long
Continuous bursts of autogrow events
Potentially a very fragmented database on disk How about 10% for log files?
12
01/05/2012
Virtual Log Files Internal structure of the physical .ldf file DBCC LOGINFO returns 1 row for every VLF
13
01/05/2012
How many is too many? Generally, anything in the 100s But it does depend on size
350GB log with 350 VLFs is a good balance
Why is it bad? Transaction log backups and restores take a lot longer The recovery process takes longer (database startup) Transactional Replication performance is affected
14
01/05/2012
What causes it? Bad autogrow values Not sizing the log properly How do I fix it? Shrink the log with DBCC SHRINKFILE User ALTER DATABASE to grow it in appropriate chunks
How do I fix it? <64MB = 4 VLFs 64MB-1GB = 8 VLFS >1GB = 16 VLFs Blog post by Kimberly Tripp
http://tinyurl.com/59mo9m
15
01/05/2012
Un-used indexes Still need to be updated Will still be part of your index maintenance How do I know if theyre not being used? Indexes that are not read from but are written to
Except unique indexes
16
01/05/2012
Join to sys.indexes to get index names Loop through each database to get object names
17
01/05/2012
18
01/05/2012
Auto-Close Database configuration option On by default in SQL Express Takes the database offline after a short period Queries can time-out as the database is starting up again Typically indicates the database has been moved from SQL Express
Auto-Shrink Database configuration option Automatically shrinks the database and log file to remove free space Often leads to a cycle of autogrow and autoshrink every day Turn it off and right-size your database
19
01/05/2012
Max Degree of Parallelism The maximum number of threads to use in a parallel plan
20
01/05/2012
What can go wrong? Lots of processes running parallel tasks can cause thread starvation
SELECT max_workers_count FROM sys.dm_os_sys_info SELECT count(*) FROM sys.dm_os_workers
21
01/05/2012
Optimize queries to remove parallelism where possible Significantly reduce Max Degree of Parallelism to allow more simultaneous executions Raise the cost threshold for parallelism from the default of 5
Can be useful to only focus on more expensive plans
22
01/05/2012
Default sizing
Physical Properties
tempdev primary data templog log Tempdb.mdf Templog.ldf 8.0 MB 1 MB SQL Server is restarted
23
01/05/2012
Size your tempdb properly Its hard to say how much is enough
Usually GBs
24
01/05/2012
Allocation Contention
TEMPDB
PFS 64MB SGAM 4GB SGAM PFS
25
01/05/2012
26