You are on page 1of 82

A Look at the Tools and Configuring

SQL Server 2008

Presented by Scott Whigham


What We’re Going to Cover

Configuration
The Tools
Overview

• Overview • An • Configuring
of Chapter Overview SQL Server
of the Tools 2008
• Demo
This Chapter

• What this chapter covers


– What has been installed
– An overview of each of the tools
• Answering The Three W’s:
– What it is, What it does, Who Uses It
– An overview of configuring the server
This Chapter

• What this chapter does NOT cover


– An overview of configuring databases
– In-depth coverage of all tools
– Every single server option available
– Cover every tool available
What We’re Going to Cover

Configuration
The Tools
Overview

• Overview • An • Configuring
of Chapter Overview SQL Server
of the Tools 2008
• Demo
An Overview of What Is Installed

• There are tools available for:


– Administrators
• SQL Server Database Administrators (DBAs)
• Reporting Services Administrators
• Analysis Services Administrators
• Systems Administrators
– Developers
• SQL Programmers
• Report developers
• Integration Services developers
• Analysis Services developers
An Overview of What Is Installed

• There are tools available for:


– Command line only
– GUI (“Graphical User Interface”)
– APIs (“Application Programming Interface”)
• Let’s look at each
Command line tools

• Command line tools primarily target


DBAs
Tool Who uses? Description
sqlcmd.exe DBAs, Developers Command line queries/batches
dtexec.exe DBAs Execute SSIS packages
sqldiag.exe DBAs Diagnostics, system info, monitor, troubleshoot
bcp.exe DBAs Import/export text files
profiler.exe DBAs Trace server activity
GUI tools

• GUI tools are for everyone!


Tool Who uses? Description

SQL Server DBAs, Developers Queries, management, security


Management Studio
(SSMS)
Business Intelligence Developers Develop/edit reports, SSIS packages, SSAS
Development Studio
(BIDS)
Visual Studio 2008 Developers It is the “real” name of BIDS

SQL Server DBAs Manage services, aliases, and network


Configuration configuration
Manager
GUI tools

• More GUI tools


Tool Who uses? Description

SQL Server Profiler DBAs Trace server activity

Database Engine DBAs Performance tuning, optimizations


Tuning Advisor
Data Profile Viewer DBAs View stats on column/table usage
Command line tools

• APIs are for developers and integrators


API Who uses? Description
SQL Server Developers Manage SQL Server via programming interfaces
Management Objects
(SMO)
SQL Server Replication Developers Manage replication via programming interfaces
Management Objects
(RMO)
Data Collector Developers Capture, store and report on
performance/health stats
Native Client Developers Combines both ODBC and OLE-DB into one DLL
WMI Developers Use WMI for server events and configuration
In the next video…

Configuration
The Tools
Overview

• Overview • An • Configuring
of Chapter Overview SQL Server
of the Tools 2008
• Demo
A Look at the Tools and Configuring
SQL Server 2008

Presented by Scott Whigham


What We’re Going to Cover

Configuration
The Tools
Overview

• Overview • An • Configuring
of Chapter Overview SQL Server
of the Tools 2008
• Demo
Configuration

• You can configure SQL Server at the


instance and database level
• This chapter covers the instance level
• Next chapter covers the database level
Configuration

• Instance-level configurations affect all


connections and all databases for that
instance
• You can change settings using
– SQL Server Management Studio
– SQL Server Configuration Manager
– sqlcmd.exe
– SQL Server Management Objects (SMO) API
Configuration

• Commonly changed configurations are:


– Service accounts
– Network protocols
– Memory, CPU
– Authentication mode and auditing
– Connection options
– Default file locations, compression settings
• Let’s look at each one
Configuration

• Commonly changed configurations are:


– Service accounts
– Network protocols
– Memory, CPU
– Authentication mode and auditing
– Connection options
– Default file locations, compression settings
• Let’s look at each one
Configuration: Service Accounts

• Service accounts are not static


– Change passwords
– Change accounts
• Changing anything here can be an
exciting experience
• To change, use the SQL Server
Configuration Manager
Configuration: Service Accounts

• To modify the service accounts, use the


SQL Server Configuration Manager
Configuration: Service Accounts
Configuration

• Commonly changed configurations are:


– Service accounts
– Network protocols
– Memory, CPU
– Authentication mode and auditing
– Connection options
– Default file locations, compression settings
• Let’s look at each one
Configuration: Network Protocols

• Network protocols define what


connections SQL Server will accept
Configuration: Network Protocols

• If SQL Server has TCP/IP enabled but all


others disabled, only clients using TCP/IP
for connections would be allowed
– Both the server and client must use the same
protocol
Configuration: Network Protocols

• Shared Memory
– Connections and data are not transferred across IP
stack; done in memory
– Clearly this only works when the client and server
are on the same machine
– For remote connections, must use one of the
other network protocols
Configuration: Network Protocols

• How to Enable Remote Connections


– Default for Express and Developer editions is to
turn off remote connections
• This is done by disabling all protocols except Shared
Memory

• To enable remote connections:


1. Enable TCP/IP or one of the other network
protocols
2. Restart SQL Server instance
Configuration: Network Protocols

• TCP/IP is most common


– Requires a unique port per instance
– Default port for default instance is 1433
– Named instances use a random-first-time port
Configuration: Network Protocols

• Change/view settings in the


Configuration Manager
– Any changes here require restarting instance
Configuration: Service Accounts
In the next video…

Configuration
The Tools
Overview

• Overview • An • Configuring
of Chapter Overview SQL Server
of the Tools 2008
• Demo
A Look at the Tools and Configuring
SQL Server 2008

Presented by Scott Whigham


What We’re Going to Cover

Configuration
The Tools
Overview

• Overview • An • Configuring
of Chapter Overview SQL Server
of the Tools 2008
• Demo
Configuration: Memory, CPU

• Memory and CPU usage can change


– When new hardware is added
– When the application’s usage changes
• Some changes require restarting the SQL
Server service but most are dynamic
• Let’s look at memory in this video
Configuration

• Commonly changed configurations are:


– Service accounts
– Network protocols
– Memory, CPU
– Authentication mode and auditing
– Connection options
– Default file locations, compression settings
• Let’s look at each one
Configuration: Memory, CPU

• Memory is used the most in two areas


– Buffer cache
• Stores the data users are working with in memory to
avoid reading disk on commonly-requested data
– Procedure cache
• SQL Server caches the “how” of running queries and
routines to avoid having to figure out the fastest route
to the data on subsequent calls
– The “how” is the “Execution Plan”
Configuration: Memory, CPU

• Sizing the Buffer Cache


– Too small means that users have to wait for SQL
Server to access hard disk
– Too large means that the operating system and/or
other applications do not have enough memory
Configuration: Memory, CPU

• Buffer cache as a percentage of the data


file size
– The larger the database, the smaller the
percentage of the size
• A 10TB system with 10 concurrent users likely needs a
1-2% buffer cache
• A 10GB system with 100 concurrent users may need as
much as a 25% buffer cache
Configuration: Memory, CPU

• The Buffer Cache should be expected to


be between 5 and 25% of the data file
size for an online transaction processing
(OLTP) system
– Should be a bit larger percentage for reporting
Configuration: Memory, CPU

• Sizing the Procedure Cache


– On a 32-bit system, the procedure cache is limited
to 1GB
• Cannot use Address Windowing Extensions (AWE)
– On a 64-bit system, procedure cache can be larger
• This is necessary on larger systems
Configuration: Memory, CPU

• Memory options you can change


– Max server memory
• Always, always set this to avoid a too-large buffer cache
– Min server memory
– Using Address Windowing Extensions (AWE)
• Only used in 32-bit installations when there is > 4GB of
RAM
Configuration: Memory, CPU

• Memory options you can change (cont.)


– Index create memory
• Specifies the amount of memory to use in index
creation sorts
• 0 means dynamic
• Have a good reason to change
Configuration: Memory, CPU

• Memory options you can change (cont.)


– Minimum memory per query
• Specifies the amount of memory to use for execution of
a query
• 0 means dynamic – 1024KB is default
• Have a good reason to change
In the next video…

Configuration
The Tools
Overview

• Overview • An • Configuring
of Chapter Overview SQL Server
of the Tools 2008
• Demo
A Look at the Tools and Configuring
SQL Server 2008

Presented by Scott Whigham


What We’re Going to Cover

Configuration
The Tools
Overview

• Overview • An • Configuring
of Chapter Overview SQL Server
of the Tools 2008
• Demo
Configuration

• Commonly changed configurations are:


– Service accounts
– Network protocols
– Memory, CPU
– Authentication mode and auditing
– Connection options
– Default file locations, compression settings
• Let’s look at each one
Configuration: Memory, CPU

• CPU settings that can be changed


– Enable/disable processors
• Licensing needs
• System performance
– Affinity mask options
• Processor affinity: binds processors to specific threads
to prevent switching mid-execution
• I/O affinity: binds disk I/O to specific processors
Configuration: Memory, CPU

• CPU settings that can be changed (cont.)


– Maximum worker threads
• CPUs do work on threads
• Do you need to set a maximum?
– Default is “0” which means dynamic
– Boost SQL Server priority – specifies whether SQL
Server process should execute at a higher priority
• Advanced option
Configuration: Memory, CPU

• Parallel queries are queries whose work


is split among CPUs
• “Cost” is a metric of time
– A query with a cost of 1 says that theoretically will
take 1 second
• This was determined pre-release in the Microsoft labs
therefore it will not likely match your system
performance
Configuration: Memory, CPU

• You can configure how SQL Server


handles parallel queries
– Cost threshold for parallelism
• SQL Server does not run a parallel plan for queries that
“cost” less than this amount
• Default value is 5
– This means that a query has to be estimated to run for 5
seconds before SQL Server will consider using a parallel plan
– 5 is the default for a very good reason
Configuration: Memory, CPU

• You can configure how SQL Server


handles parallel queries (cont.)
– Max degree of parallelism
• Controls how many processors are available to run a
single statement
• Default value is “0” which means to use all available
CPUs
• Can be overridden at query level
In the next video…

Configuration
The Tools
Overview

• Overview • An • Configuring
of Chapter Overview SQL Server
of the Tools 2008
• Demo
A Look at the Tools and Configuring
SQL Server 2008

Presented by Scott Whigham


What We’re Going to Cover

Configuration
The Tools
Overview

• Overview • An • Configuring
of Chapter Overview SQL Server
of the Tools 2008
• Demo
Configuration

• Commonly changed configurations are:


– Service accounts
– Network protocols
– Memory, CPU
– Authentication mode and auditing
– Connection options
– Default file locations, compression settings
Configuration: Security

• Security settings that can be changed:


– Authentication mode
• Requires restarting SQL Server service to take effect
– Login auditing
• Bare auditing – doesn’t record too much information
– None, Failed only, Successful only, Both
– Server Proxy Account
• Used with xp_cmdshell
• Not likely to use but, if you do, be careful
Configuration: Security

• Security settings that can be changed (cont.):


– Enable Common Criteria Compliance
• Forces SQL Server to adhere to Common Criteria compliance
• Developer and Enterprise edition only
• More info: http://www.commoncriteriaportal.org/
– Enable C2 audit tracing
• Audits all attempts to access statements and objects to
file(s)
– Cross database ownership chaining
• Coming up in later chapter
Configuration

• Commonly changed configurations are:


– Service accounts
– Network protocols
– Memory, CPU
– Authentication mode and auditing
– Connection options
– Default file locations, compression settings
• Let’s look at each one
Configuration: Connections

• Connection options affect all connections


to the instance
– Some can be overridden at connection level
• Triple check this in development/testing
before deployment
– One setting change can cause critical parts of an
application to fail
Configuration: Connections

• Connection options you can change:


– Maximum number of concurrent connections
• Default is “0” which is no limit
– Use Query Governor to prevent long-running
queries
• Great idea in theory; better to use Resource Governor
Configuration: Connections

• Connection options you can change


(cont.):
– Allow remote server connections
• Do you want remote servers to run stored procedures
on this server?
– Require distributed transactions for server-to-
server communication
• Uses Microsoft DTC to ensure that transactions
completely succeed on all servers
Configuration: Connections

• Common connection options


– All are “Off” by default
– This allows client to set it’s own defaults
Setting Description Default
ansi nulls Does the statement Statement would return 0
“WHERE LastName = rows; requires ISNULL to
NULL” return any rows? test for NULL values
no count “34 rows affected”
messages are returned to
client
quoted identifier Do double quotes identify
object names or query
criteria?
In the next video…

Configuration
The Tools
Overview

• Overview • An • Configuring
of Chapter Overview SQL Server
of the Tools 2008
• Demo
A Look at the Tools and Configuring
SQL Server 2008

Presented by Scott Whigham


What We’re Going to Cover

Configuration
The Tools
Overview

• Overview • An • Configuring
of Chapter Overview SQL Server
of the Tools 2008
• Demo
Configuration

• Commonly changed configurations are:


– Service accounts
– Network protocols
– Memory, CPU
– Authentication mode and auditing
– Connection options
– Default file locations, compression settings
Configuration: File locations &
Compression

• Defaults for new databases:


– Default index fill factor
• How full should a “page” be?
• Default is to fill page completely
– Backup compression
• Sets whether a backup is compressed by default
• Any backup can be compressed or uncompressed
regardless of this setting
• For Enterprise and Developer edition
Configuration: File locations &
Compression

• Defaults for new databases (cont.)


– Database default locations
• Configure the default locations for data and log files
individually
• For new databases only
• Default locations are only used in statements that do
not specify file locations

CREATE DATABASE ScottsDB


In the next video…

Configuration
The Tools
Overview

• Overview • An • Configuring
of Chapter Overview SQL Server
of the Tools 2008
• Demo • Demo
A Look at the Tools and Configuring
SQL Server 2008

Presented by Scott Whigham


What We’re Going to Cover

Configuration
The Tools
Overview

• Overview • An • Configuring
of Chapter Overview SQL Server
of the Tools 2008
• Demo
How to Change Configuration
Settings
How to Change Configuration
Settings

• How to change configuration settings


– Use SSMS for interactive or jobs
– Use sqlcmd.exe for scripts
• Can use the GUI and Transact SQL scripts
Configuration

• GUI is great for learning


• Scripts are better for
– Change tracking
– Undoing
– Sharing across machines/users
• Changes require two things:
– The actual change
– Acknowledgement that the change should be
applied
Configuration

• Tips
– Have a “backup” or “back out” plan
– Understand that SQL Server will often clear out
portions of its memory after configuration
changes
• This can have severe short-term impact!
Configuration

• “Configured values” are what SQL Server


will change to once you click “OK”
• “Running values” are what SQL Server is
currently using
– Running values is a read-only view of what the
system is using right now
Configuration

• To change configurations in the GUI:


1. Launch SQL Server Management Studio
2. Login as a sysadmin
3. Right click on server and select Properties
• After changes, click “OK” to save
• Try, try, try not to do this during production
hours!
Configuration

• sp_configure is the Transact-SQL way to


modify server configurations
• To use sp_configure, you must first
enable the “advanced” options

EXEC sp_configure ‘show advanced’, 1


RECONFIGURE
Configuration

• sp_configure requires use of


RECONFIGURE or RECONFIGURE WITH
OVERRIDE to take effect without a
restart of SQL Server service
– Otherwise changes will not take effect until you
stop/start

EXEC sp_configure ‘show advanced’, 1


RECONFIGURE
In the next video…

Configuration
The Tools
Overview

• Overview • An • Configuring
of Chapter Overview SQL Server
of the Tools 2008
• Demo

You might also like