Sie sind auf Seite 1von 61

1

Top 10 Practices to Keep


SQL Databases Healthy
Paul Berrigan, MCDBA
Product Database Administrator
Kronos Incorporated
2
Setting the Stage
• Session purpose:
– Provide valuable information!
– Give you access to the lessons we have learned
– Empower you to proactively maintain your Kronos
solution
– Let you know about other ways we can help

• Session content:
– Somewhat technical
– Great for IT folks!
– Good for payroll, HR and operations!
KronosAtYourService@kronos.com
3
Agenda
• SQL Server and Database Settings
– Are your database and server settings optimally set to improve
performance?
• Pre-Allocating Space for Existing Filegroups
– Are your filegroups sized for future growth?
• Updating Statistics
– Are you updating your database statistics for top performance?
• Managing Indexes
– Are you managing your database indexes for top performance?
• Database Fragmentation
– How can you eliminate or reduce index fragmentation?
• Backing Up Databases
– Does your backup strategy meet your business requirements?

KronosAtYourService@kronos.com
4
Agenda

• Transaction Logs
– Do you understand transaction log management?

• Discontinued Support of Automated SQL Server Database


Maintenance Utilities
– Is your database maintenance plan up-to-date?

• Proactive Database Server Maintenance


– How can you proactively monitor your database server to prevent
issues?

• Checking Database Integrity


– Do you routinely check your database for integrity errors?

• Questions and Answers


KronosAtYourService@kronos.com
5
Agenda
• SQL Server and Database Settings
– Are your database and server settings optimally set to improve
performance?
• Pre-Allocating Space for Existing Filegroups
– Are your filegroups sized for future growth?
• Updating Statistics
– Are you updating your database statistics for top performance?
• Managing Indexes
– Are you managing your database indexes for top performance?
• Database Fragmentation
– How can you eliminate or reduce index fragmentation?
• Backing Up Databases
– Does your backup strategy meet your business requirements?

KronosAtYourService@kronos.com
6
SQL Server and Database Settings

Max degree of parallelism


• Kronos recommends setting the max degree of
parallelism parameter equal to 1.
• This value identifies the number of threads used to
execute a parallel plan.
• Changing this setting will minimize blocks and
reduce blocking.

KronosAtYourService@kronos.com
7
SQL Server and Database Settings

Max degree of parallelism reduces…


• Locks
• Blocking
• Deadlocks

KronosAtYourService@kronos.com
8
SQL Server and Database Settings

How to change the max


degree of parallelism
• SQL statements or through
Enterprise Manager

KronosAtYourService@kronos.com
9
SQL Server and Database Settings

Default index fill factor


• Kronos recommends setting the default index fill
factor to 75%.
• This setting allows space left on index pages and
allows for future growth of indexes.
• Database fragmentation occurs more frequently if
this parameter is not correctly specified.

KronosAtYourService@kronos.com
10
SQL Server and Database Settings

How to change the default


index fill factor
• SQL statements or through
Enterprise Manager

KronosAtYourService@kronos.com
11
SQL Server and Database Settings

Disable the auto update statistics


setting
• Kronos recommends disabling the
auto update statistics setting for the
Workforce Central® database.
• Allowing SQL Server to perform an
auto update could make performance
worse.
• Kronos recommends manually
updating statistics.

KronosAtYourService@kronos.com
12
SQL Server and Database Settings

How to disable auto


update statistics
• SQL statements or through
Enterprise Manager

KronosAtYourService@kronos.com
13
SQL Server and Database Settings

Disable the auto shrink setting


• Kronos recommends disabling the auto shrink
setting.
• This setting will attempt to shrink database files
when the file contains unused space.
• If auto shrink is enabled, SQL Server may use
unnecessary system resources.

KronosAtYourService@kronos.com
14
SQL Server and Database Settings

How to disable auto shrink


• SQL statements or through
Enterprise Manager.

KronosAtYourService@kronos.com
15
Agenda
• SQL Server and Database Settings
– Are your database and server settings optimally set to improve
performance?
• Pre-Allocating Space for Existing Filegroups
– Are your filegroups sized for future growth?
• Updating Statistics
– Are you updating your database statistics for top performance?
• Managing Indexes
– Are you managing your database indexes for top performance?
• Database Fragmentation
– How can you eliminate or reduce index fragmentation?
• Backing Up Databases
– Does your backup strategy meet your business requirements?

KronosAtYourService@kronos.com
16
Pre-Allocating Space for
Existing Filegroups

Are your filegroups sized for future growth?


• Kronos recommends allowing room for future data
growth.
• Review your Hardware Recommendations Report.
• Existing filegroups can be expanded to
accommodate future growth.

KronosAtYourService@kronos.com
17
Pre-Allocating Space for
Existing Filegroups

Pre-allocate
space for existing
SQL Server
filegroups to
avoid disk
fragmentation

KronosAtYourService@kronos.com
18
Poll Question #1

Are your server and database settings set correctly?

• Yes
• No
• Don’t know

KronosAtYourService@kronos.com
19
Agenda
• SQL Server and Database Settings
– Are your database and server settings optimally set to improve
performance?
• Pre-Allocating Space for Existing Filegroups
– Are your filegroups sized for future growth?
• Updating Statistics
– Are you updating your database statistics for top performance?
• Managing Indexes
– Are you managing your database indexes for top performance?
• Database Fragmentation
– How can you eliminate or reduce index fragmentation?
• Backing Up Databases
– Does your backup strategy meet your business requirements?

KronosAtYourService@kronos.com
20
Updating Statistics

Are you updating your database statistics


for top performance?
• SQL Server’s query optimizer uses database
statistics to determine the most efficient way to
retrieve the data.
• Kronos often recommends updating statistics using
the fullscan (100% sample size) option.
• Outdated statistics can cause inefficient query
plans, which can result in poor performance.

KronosAtYourService@kronos.com
21
Updating Statistics

Manually updating statistics


• Scheduling your update statistics job to run after
hours may avoid potential performance problems.
• Updating statistics manually allows users to specify
the highest possible sample size.
• You can compute statistics for all tables or specific
tables rather than relying on SQL Server.

KronosAtYourService@kronos.com
22
Agenda
• SQL Server and Database Settings
– Are your database and server settings optimally set to improve
performance?
• Pre-Allocating Space for Existing Filegroups
– Are your filegroups sized for future growth?
• Updating Statistics
– Are you updating your database statistics for top performance?
• Managing Indexes
– Are you managing your database indexes for top performance?
• Database Fragmentation
– How can you eliminate or reduce index fragmentation?
• Backing Up Databases
– Does your backup strategy meet your business requirements?

KronosAtYourService@kronos.com
23
Managing Indexes

What are indexes?


• A SQL Server index is an internal data
structure that optimizes access to data.
• An index tells SQL Server where a
certain row is located given an
indexed-column value.
• Indexes must be properly maintained to
ensure optimal database performance.

KronosAtYourService@kronos.com
24
Managing Indexes

What types of indexes does SQL server support?


• There are two types of SQL Server indexes:
clustered indexes and nonclustered indexes.
• A clustered index is similar to a telephone directory,
which arranges data by last name.
• A nonclustered index is similar to an index in a
textbook.

KronosAtYourService@kronos.com
25
Managing Indexes

Clustered and
nonclustered indexes
on the person table

KronosAtYourService@kronos.com
26
Poll Question #2

Are you currently updating database statistics


and maintaining your indexes?

• Yes
• No
• Don’t know

KronosAtYourService@kronos.com
27
Agenda
• SQL Server and Database Settings
– Are your database and server settings optimally set to improve
performance?
• Pre-Allocating Space for Existing Filegroups
– Are your filegroups sized for future growth?
• Updating Statistics
– Are you updating your database statistics for top performance?
• Managing Indexes
– Are you managing your database indexes for top performance?
• Database Fragmentation
– How can you eliminate or reduce index fragmentation?
• Backing Up Databases
– Does your backup strategy meet your business requirements?

KronosAtYourService@kronos.com
28
Database Fragmentation

What is database fragmentation?


• Fragmentation occurs when the logical order of the
pages is incorrect.
• Fragmentation occurs when data is added or
removed from a table.
• The DBCC SHOWCONTIG command displays
fragmentation information.

KronosAtYourService@kronos.com
29
Database Fragmentation

How can you eliminate or reduce index


fragmentation?
• Use the DBCC DBREINDEX statement.
• Use the DBCC INDEXDEFRAG statement.
• Use the DROP INDEX and CREATE INDEX
statements.

KronosAtYourService@kronos.com
30
Database Fragmentation

Other considerations
• The DBCC DBREINDEX statement should be run
when users are not connected to the database.
• While running DBCC DBREINDEX, the tables are
unavailable to users.
• The frequency of running DBCC DBREINDEX
depends on the amount of fragmentation.

KronosAtYourService@kronos.com
31
Agenda
• SQL Server and Database Settings
– Are your database and server settings optimally set to improve
performance?
• Pre-Allocating Space for Existing Filegroups
– Are your filegroups sized for future growth?
• Updating Statistics
– Are you updating your database statistics for top performance?
• Managing Indexes
– Are you managing your database indexes for top performance?
• Database Fragmentation
– How can you eliminate or reduce index fragmentation?
• Backing Up Databases
– Does your backup strategy meet your business requirements?

KronosAtYourService@kronos.com
32
Backing Up Databases

Does your backup strategy meet your business


requirements?
• How much data can you afford to lose?
• Database backups are critical to ensure the success
of any disaster recovery plan.
• Backup files should be stored to disk files (local or
network) or tape.

KronosAtYourService@kronos.com
33
Backing Up Databases

Backup strategy considerations


• Backup plans should be documented.
• The restore process and the requirements of each
backup method should be considered.
• The backup plan should be tested periodically.

KronosAtYourService@kronos.com
34
Backing Up Databases

Which system (SQL Server) databases should be


considered for backup?
• The MASTER database contains information about all
SQL Server databases and should be considered for
backup.
• The MSDB database contains information about jobs,
alerts, and notifications and should be considered for
backup.
• The MODEL database contains default information
about new databases and should be considered for
backup.
KronosAtYourService@kronos.com
35
Backing Up Databases

Types of SQL Server backups


• Full backups provide a baseline for database
recovery.
• Differential backups include database
changes since the last full backup.
• Transaction log backups record any database
changes.
• Database file or filegroup backups allow copies
of specific database files. (Not recommended
for Workforce Central).
KronosAtYourService@kronos.com
36
Backing Up Databases

Database failure

Monday Monday Monday Monday Monday


@12:00AM @6:00AM @7:00AM @8:00AM @8:35AM
Daily Full DB Tran Log Tran Log Tran Log Disk
Backup Backup Backup Backup Failure

KronosAtYourService@kronos.com
37
Backing Up Databases

Restoring a database backup with transaction logs

Restore the daily Apply the previous Database


full backup from transaction log restored to a
Monday backups from point in time
@12:00AM Monday (before (@8:00AM)
the crash)

6:00AM
7:00AM
8:00AM

KronosAtYourService@kronos.com
38
Poll Question #3

Do you currently have a valid backup strategy in


place?

• Yes
• No
• Don’t know

KronosAtYourService@kronos.com
39
Agenda

• Transaction Logs
– Do you understand transaction log management?

• Discontinued Support of Automated SQL Server Database


Maintenance Utilities
– Is your database maintenance plan up-to-date?

• Proactive Database Server Maintenance


– How can you proactively monitor your database server to prevent
issues?

• Checking Database Integrity


– Do you routinely check your database for integrity errors?

• Questions and Answers


KronosAtYourService@kronos.com
40
Transaction Logs

Understanding your transaction log


• A transaction log is used to record transactions.
• The transaction log enables point-in-time recovery
of a database in case of failure.
• Importing person records, adding punches,
calculating trial payroll, and database maintenance
plan activity can increase the size of the
transaction log.

KronosAtYourService@kronos.com
41
Transaction Logs

Maintaining and managing your transaction log


• The process of deleting old log records to reduce
the size of the logical log is called truncating the
transaction log.
• Never delete your transaction log (.LDF) file.
• The recovery model determines the amount of
data that is written to the transaction log.

KronosAtYourService@kronos.com
42
Agenda

• Transaction Logs
– Do you understand transaction log management?

• Discontinued Support of Automated SQL Server


Database Maintenance Utilities
– Is your database maintenance plan up-to-date?

• Proactive Database Server Maintenance


– How can you proactively monitor your database server to prevent
issues?

• Checking Database Integrity


– Do you routinely check your database for integrity errors?

• Questions and Answers


KronosAtYourService@kronos.com
43
Discontinued Support of Automated SQL
Server Database Maintenance Utilities

Zero DBA maintenance tasks are a thing of


the past!
• Kronos has discontinued the support and
installation of automated SQL Server database
maintenance utilities.
• Under certain conditions, these jobs may cause
problems.
• You can improve your maintenance tasks!

KronosAtYourService@kronos.com
44
Discontinued Support of Automated SQL
Server Database Maintenance Utilities

Outdated
automated SQL
Server database
maintenance
utilities

KronosAtYourService@kronos.com
45
Poll Question #4

Is your database maintenance plan up-to-date?

• Yes
• No
• Don’t know

KronosAtYourService@kronos.com
46
Agenda

• Transaction Logs
– Do you understand transaction log management?

• Discontinued Support of Automated SQL Server Database


Maintenance Utilities
– Is your database maintenance plan up-to-date?

• Proactive Database Server Maintenance


– How can you proactively monitor your database server to prevent
issues?

• Checking Database Integrity


– Do you routinely check your database for integrity errors?

• Questions and Answers


KronosAtYourService@kronos.com
47
Proactive Database
Server Maintenance

How can you proactively monitor


your database server to prevent issues?
• The Kronos reconcile reports should be run
regularly.
• All database maintenance jobs should be reviewed
regularly.
• Periodic disk defragmentation should be run on the
database server. (This does not apply in a SAN
environment).

KronosAtYourService@kronos.com
48
Proactive Database
Server Maintenance

The Kronos reconcile report – object


reconciliation report
• Verifies all Kronos objects exist and have
appropriate permissions.
• Lists any objects that do not exist or have
insufficient permissions.
• Lists any non Kronos objects within the Workforce
Central database.

KronosAtYourService@kronos.com
49
Proactive Database
Server Maintenance

The Kronos reconcile report – object reconciliation report

KronosAtYourService@kronos.com
50
Proactive Database
Server Maintenance

The Kronos reconcile report –


schema reconciliation report
• Verifies information about integrity constraints,
indexes, and columns.
• Verifies sequence counters are valid.
• Does not validate actual data.

KronosAtYourService@kronos.com
51
Proactive Database
Server Maintenance
The Kronos reconcile report – schema reconciliation report

KronosAtYourService@kronos.com
52
Proactive Database
Server Maintenance

Review all of your maintenance jobs in Enterprise


Manager to determine success or failure

KronosAtYourService@kronos.com
53
Proactive Database
Server Maintenance

Use windows disk


defragmenter to
identify fragmented
files and use a disk
defragmenter tool
to clean up
fragmentation.
(This does not
apply in a SAN
environment)

KronosAtYourService@kronos.com
54
Poll Question #5

Do you proactively monitor your database server?

• Yes
• No
• Don’t know

KronosAtYourService@kronos.com
55
Agenda

• Transaction Logs
– Do you understand transaction log management?

• Discontinued Support of Automated SQL Server Database


Maintenance Utilities
– Is your database maintenance plan up-to-date?

• Proactive Database Server Maintenance


– How can you proactively monitor your database server to prevent
issues?

• Checking Database Integrity


– Do you routinely check your database for integrity errors?

• Questions and Answers


KronosAtYourService@kronos.com
56
Checking Database Integrity

Do you routinely check your database for


integrity errors?
• Schedule the DBCC CHECKDB statement to run as
part of your maintenance plan.
• Review the output of this statement to identify
consistency errors, allocation errors, or torn pages.
• Errors from this report may result in data loss or the
restoration of a backup.

KronosAtYourService@kronos.com
57
Checking Database Integrity

Running
DBCC
CHECKDB

KronosAtYourService@kronos.com
58
Microsoft SQL Server 2005

• Microsoft SQL
Server 2005
supports Workforce
Central 5.2 (not
Workforce HR™ or
Workforce Payroll™)
• Microsoft SQL
Server Management
Studio replaces
Enterprise Manager
• Additional security
features, online
indexes, etc.

KronosAtYourService@kronos.com
59
Thanks For Listening!
Kronos At Your Service – For more information please call:

1 (877) 844-1438 (U.S. toll free)


Or contact your local Sales Representative

Kronos Services portfolio:


• SYSTEM HEALTH CHECK
Think of it as a regularly scheduled • Business consulting
preventative trip to your family doctor
• Educational services
• Implementation services
• TECHNICAL MENTORING • Mentoring and knowledge
Hands-on knowledge transfer
transfer services
• Solution optimization
• DATABASE SUPPORT consulting
SERVICES
Proactively manage your database with • Support services
expert service
• Staff augmentation services

Maximize value and operational efficiency throughout your entire


solution lifecycle!
KronosAtYourService@kronos.com
60
©2007, Kronos Incorporated. Kronos, and the Kronos logo are registered trademarks and “Experts at Improving the Performance of People and Business” is a trademark of Kronos
Incorporated or a related company. All other products or company names mentioned are used for identification purposes only and may be trademarks of their respective owners.
All rights reserved. Printed in the U.S.A.
61

Das könnte Ihnen auch gefallen