Identify and Resolve Database Performance Problems
Identify and Resolve Database Performance Problems
1. MS SQL Maestro is an excellent Microsoft SQL database administration tool. It has all the functions that you
would ever need such as: managing your SQL server, creating and dropping databases, managing data inside
the tables, executing SQL queries, and more.
2. SQL Server Comparison Tool is a Windows program for analyzing, comparing and documenting SQL Server
databases.
3. SQL Server Comparison Expert is a database software tool which provides you with very useful comparison
functionality, such as database analysis, repairing, comparison and synchronization, backup and restore.
1.1.2. run diagnostic tools
1.1.1.1 Identify latch contentions
1
Identify and Resolve Database Performance Problems
Latches are low level serialization mechanisms used to protect shared data structures system global area.
The implementation of latches is operating system dependent, particularly in regard to whether a process will wait
for a latch and for how long.
A latch is a type of a lock that can be used to prevent more than one process from executing the same piece of code
at a given time.
1.1.1.1 Identify events causing waits and record outcomes
SQL Server Extended Events (Extended Events) is a general event-handling system for server systems.
The Extended Events infrastructure supports the correlation of data from SQL Server, and under certain conditions,
the correlation of data from the operating system and database applications. In the latter case, Extended Events
output must be directed to Event Tracing for Windows (ETW) in order to correlate the event data with operating
system or application event data.
1.4 Fixing the Database based on diagnostic results
When problems occur with a system, it is important to perform accurate and timely diagnosis of the problem before
making any changes to a system. Often a database administrator (DBA) simply looks at the symptoms and
immediately starts changing the system to fix those symptoms. However, long-time experience has shown that an
initial accurate diagnosis of the actual problem significantly increases the probability of success in resolving the
problem.
Automatic Database Diagnostic Monitor
The types of problems that ADDM considers include:
CPU bottlenecks
Undersized Memory Structures
I/O capacity issues
Database configuration issues
Concurrency issues
In addition to problem diagnostics, ADDM recommends possible solutions. When appropriate, ADDM recommends
multiple solutions for the DBA to choose from.
The recommendations include:
Hardware changes - Adding CPUs or changing the I/O subsystem configuration
Schema changes
2
Identify and Resolve Database Performance Problems
Application changes
Centralized Systems
All DBMS functionality, application program execution, and user interface
processing carried out on one machine
Run on a single computer system and do not interact with
other computer systems
3
Identify and Resolve Database Performance Problems
4
Identify and Resolve Database Performance Problems
Transaction Servers
Also called query server systems or SQL server systems;
clients send requests to the server system where the
transactions are executed, and results are shipped back to
the client.
Requests specified in SQL, and communicated to the
server through a remote procedure call (RPC)
mechanism.
Transactional RPC allows many RPC calls to collectively form
a transaction.
Open Database Connectivity (ODBC) is an application
program interface standard from Microsoft for connecting
to a server, sending SQL requests, and receiving results.
Data Servers
Used in LANs, where there is a very high speed connection
between the clients and the server, the client machines are
comparable in processing power to the server machine, and
the tasks to be executed are compute intensive.
Ship data to client machines where processing is
performed, and then ship results back to the server
machine.
This architecture requires full back-end functionality at the
clients.
Used in many object-oriented database systems
Issues:
Page-Shipping versus Item-Shipping
5
Identify and Resolve Database Performance Problems
Locking
Data Caching
Lock Caching
Page-Shipping versus Item-Shipping
– Smaller unit of shipping ) more messages
– Worth prefetching related items along with requested item
– Page shipping can be thought of as a form of prefetching
_ Locking
– Overhead of requesting and getting locks from server is
high due to message delays
– Can grant locks on requested and prefetched items; with
page shipping, transaction is granted lock on whole page.
– Locks on the page can be deescalated to locks on items in
the page when there are lock conflicts. Locks on unused
items can then be returned to server.
Data Caching
– Data can be cached at client even in between transactions
– But check that data is up-to-date before it is used (cache
coherency)
– Check can be done when requesting lock on data item
_ Lock Caching
– Locks can be retained by client system even in between
transactions
– Transactions can acquire cached locks locally, without
contacting server
– Server calls back locks from clients when it receives
conflicting lock request. Client returns lock once no local
6
Identify and Resolve Database Performance Problems
Parallel Systems
Parallel database systems consist of multiple processors and
multiple disks connected by a fast interconnection network.
_ A coarse-grain parallel machine consists of a small number
of
powerful processors; a massively parallel or fine grain
machine
utilizes thousands of smaller processors.
_ Two main performance measures:
– throughput — the number of tasks that can be completed
in a given time interval
– response time — the amount of time it takes to complete a
single task from the time it is submitted
7
Identify and Resolve Database Performance Problems
Shared Memory
Processors and disks have access to a common memory,
typically via a bus or through an interconnection network.
_ Extremely efficient communication between processors —
data
in shared memory can be accessed by any processor without
having to move it using software
Shared Disk
All processors can directly access all disks via an
interconnection network, but the processors have private
memories.
– The memory bus is not a bottleneck
– Architecture provides a degree of fault-tolerance — if a
processor fails, the other processors can take over its tasks
since the database is resident on disks that are accessible
from all processors.
8
Identify and Resolve Database Performance Problems
Shared Nothing
Node consists of a processor, memory, and one or more
disks.
Processors at one node communicate with another processor
at another node using an interconnection network. A node
functions as the server for the data on the disk or disks the
node owns.
Data accessed from local disks (and local memory accesses)
do not pass through interconnection network, thereby
minimizing the interference of resource sharing.
Hierarchical
Combines characteristics of shared-memory, shared-disk,
and
shared-nothing architectures.
_ Top level is a shared-nothing architecture – nodes
connected
by an interconnection network, and do not share disks or
memory with each other.
_ Each node of the system could be a shared-memory system
with a few processors.
Distributed Systems
Data spread over multiple machines (also referred to as sites
or nodes).
9
Identify and Resolve Database Performance Problems
Network Types
Local-area networks (LANs) – composed of processors that
10
Identify and Resolve Database Performance Problems
Backup is the process by which you make a copy of your work for safekeeping in an alternate location, in case your
current work becomes lost or corrupt. The backup copy is only as recent as the last time it was modified. The more
work you do, the more frequently you should back up your work.
Before creating databases and schema repositories, administrators should establish procedures and schedules for
regular backups.
- Backups can be performed using backup tools provided by the database vendors and third parties.
- Backups should also be performed before moving schema repositories or user databases.
Backup all databases at the same time, including schema repositories and all associated user databases preserves
both data and customizations, and ensures that schema repositories and user databases are synchronized in case they
need to be restored from a backup.
› Backup Option/Tool
There are only two commands for backup, the primary is BACKUP DATABASE. This allows you to do a complete
backup of your database as well as differential, file, etc.
The BACKUP DATABASE command gives you many options for creating backups.
› Create a full backup to disk
The command is BACKUP DATABASE databaseName. The "TO DISK" option specifies that the backup should
be written to disk and the location and filename to create the backup is specified.
Secure Backup
Passwords are not required to perform backup operations, but they provide an added level of security. You can use
them in addition to using SQL Server security roles. The use of password protection helps guard against
unauthorized or unintentional actions such as:
Restoration of databases
14
Identify and Resolve Database Performance Problems
Note: The database must have full back up in order to take a differential backup, it only backups the changes since
last full backup.
15
Identify and Resolve Database Performance Problems
Backup Mode
Offline
Offline backup is a way to store files from a network so that they will be accessible even when the user is not
connected to the network they are stored on.
Online
Online backup, also known as remote backup, is a method of offsite data storage in which files, folders, or the entire
contents of a hard drive are regularly backed up on a remote server or computer with a network connection.
Online backup means to back up data from your hard drive to a remote server or computer using a network
connection.
Database tuning describes a group of activities used to optimize and homogenize the performance of a database.
Database tuning aims to maximize use of system resources to perform work as efficiently and rapidly as possible.
Microsoft SQL Server provides a comprehensive set of tools for monitoring events in SQL Server and for tuning the
physical database design. The choice of tool depends on the type of monitoring or tuning to be done and the
particular events to be monitored.
Tune I/O
Hardware and software configuration of disk subsystems MUST examine:
- RAID levels and configuration,
- Block and stripe size allocation,
- The configuration of disks, controller cards, storage cabinets, and external storage systems.
Frequently accessed tables and indexes are placed on separate disks to balance I/O and prevent read queuing.
Tune memory
Memory is probably the best way to increase the performance of a database system.
Each process running on a computer requires a certain amount of memory to temporarily store its machine code
and data. Database management systems (DBMS) also employ shared memory to store data used by many client
applications. Memory tuning involves the allocation of the memory resource to the various components of the
database management system.
17
Identify and Resolve Database Performance Problems
Memory management is all about allocation of objects. A correctly tuned memory management system minimizes
the overhead inflicted by garbage collection and makes object allocation fast.
Note: - Contentions are detected, identified and resolved that may arise in the real-time operation of the database.
- Database must be reconfigured according to organizational specifications
18