0% found this document useful (0 votes)
191 views18 pages

Identify and Resolve Database Performance Problems

The document discusses identifying and resolving database performance problems. It covers diagnosing issues using tools like performance monitoring, query monitoring, and predictive alerting. Specific problems like latch contentions and events causing waits are examined. Fixing the database involves determining the diagnostic results and recommendations which may include hardware, configuration, schema, or application changes. The document also covers database architectures like centralized, client-server, parallel, and distributed systems and specifics on transaction servers and data servers.

Uploaded by

aa wants
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
191 views18 pages

Identify and Resolve Database Performance Problems

The document discusses identifying and resolving database performance problems. It covers diagnosing issues using tools like performance monitoring, query monitoring, and predictive alerting. Specific problems like latch contentions and events causing waits are examined. Fixing the database involves determining the diagnostic results and recommendations which may include hardware, configuration, schema, or application changes. The document also covers database architectures like centralized, client-server, parallel, and distributed systems and specifics on transaction servers and data servers.

Uploaded by

aa wants
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Identify and Resolve Database Performance Problems

MODULE TITLE: Identify and Resolve Database Performance Problems


LO1. Diagnose problems
1.1. Identify Diagnose Tool based on organizational database requirements
Diagnosis is the process of identification of the nature and cause of a certain phenomenon.
It is used in many different disciplines with variations in the use of logics, analytics, and experience to determine
"cause and effect".
In database system, it is typically used to determine the causes of the database problem, and the solutions.
Database problems can be detected and solved by using:
› Performance monitoring for physical and virtual databases
› Query monitoring to see the causes of blocks and deadlocks
› History browsing to find and troubleshoot past issues
› Predictive alerting with settings to avoid false alerts
› Capacity Planning to minimize server collapse

1.1.1. Obtain Diagnose Tool


Microsoft SQL Server is a database management system designed to store massive amounts of data for use in other
applications. This set of applications gives you additional tools for working with SQL Server and its databases.
The tools include:
- Monitoring tools,
- Comparison tools,
- Search tools,
- Query builders, etc.

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

 Database configuration - Changing initialization parameter settings

 Schema changes
2
Identify and Resolve Database Performance Problems

 Application changes

LO2. Configure database


2.1. Database Architecture
 Centralized Systems
 Client–Server Systems
 Parallel Systems
 Distributed Systems
 Network Types

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

 General-purpose computer system: one to a few CPUs and a


number of device controllers that are connected through a
common bus that provide access to shared memory.
 Single-user system (e.g., personal computer or workstation):
desk-top unit, single user, usually has only one CPU and one or
two hard disks; the OS may support only one user.
 Multi-user system: more disks, more memory, multiple CPUs, and
a multi-user OS. Serve a large number of users who are
connected to the system vie terminals. Often called server
systems.
Client-Server Systems
Server systems satisfy requests generated at client systems,
whose general structure is shown below:

3
Identify and Resolve Database Performance Problems

Database functionality can be divided into:


Back-end: manages access structures, query evaluation
and optimization, concurrency control and recovery.
Front-end: consists of tools such as forms, report-writers,
and graphical user interface facilities.
The interface between the front-end and the back-end is
through SQL or through an application program interface.
Advantages of replacing mainframes with networks of
workstations or personal computers connected to back-end
server machines:
better functionality for the cost
flexibility in locating resources and expanding facilities
better user interfaces
easier maintenance
Server systems can be broadly categorized into two
kinds:
 transaction servers which are widely used in
relational database systems, and
 data servers, used in object-oriented database
systems

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

transaction is using it.


– Similar to deescalation, but across transactions

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

Parallel Database Architectures


Shared memory – processors share a common memory
_ Shared disk – processors share a common disk
_ Shared nothing – processors share neither a common
memory nor common disk
_ Hierarchical – hybrid of the above architectures

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 interconnects the machines


_ Data shared by users on multiple machines
_ Illusion of a non-distributed system
_ Differentiate between local and global transactions
– A local transaction accesses data in the single site at which
the transaction was initiated.
– A global transaction either accesses data in a site different
from the one at which the transaction was initiated or
accesses data in several different sites
Sharing data – users at one site able to access the data
residing at some other sites.
_ Autonomy – each site is able to retain a degree of control
over
data stored locally.
_ Higher system availability through redundancy — data can
be
replicated at remote sites, and system can function even if a
site fails.
_ Disadvantage: added complexity required to ensure proper
coordination among sites.
– Software development cost.
– Greater potential for bugs.
– Increased processing overhead.

Network Types
Local-area networks (LANs) – composed of processors that
10
Identify and Resolve Database Performance Problems

are distributed over small geographical areas, such as a


single
building or a few adjacent buildings.
_ Wide-area networks (WANs) – composed of processors
distributed over a large geographical area.
– Discontinuous connection – WANs, such as those based on
periodic dial-up (using, e.g., UUCP), that are connected only
for part of the time.
– Continuous connection – WANs, such as the Internet,
where
hosts are connected to the network at all times.
Basics of client server architecture

Servers with specific functionalities


•File server
•Maintains the files of the client machines.
•Printer server
•Connected to various printers; all print requests by the clients are
forwarded to this machine
•Web servers or e-mail servers
Client machines
•Provide user with:
•Appropriate interfaces to use these services
•Local processing power to run local applications
DBMS example
•Server handles query, update, and transaction functionality
•Client handles user interface programs and application
programs
11
Identify and Resolve Database Performance Problems

Three tier client server DBMS architecture

Code partitioned between clients (user interfaces), application


server, and DBMS modules

2.2 Configuring a database


2.2.1 Use Database Configuration Assistance (DBCA)

 Adopting Distributed files architecture to minimize input/output contention.


Distributed file system is a method of storing and accessing files based in a client/server architecture.
In a distributed file system, one or more central servers store files that can be accessed, with proper authorization
rights, by any number of remote clients in the network.
Like an operating system organizes files in a hierarchical file management system, the distributed system uses a
uniform naming convention and a mapping scheme to keep track of where files are located.
When the client device retrieves a file from the server, the file appears as a normal file on the client machine, and the
user is able to work with the file in the same ways as if it were stored locally on the workstation.
Distributed file systems can be advantageous because they make it easier to distribute documents to multiple clients
and they provide a centralized storage system so that client machines are not using their resources to store files.

 2.3. Ensuring Database back-up procedures


12
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.

Example: BACKUP DATABASE DatabaseName TO DISK = 'D:\backupFileName.BAK'

› Create a differential backup


This command adds the "WITH DIFFERENTIAL" option.

Example: BACKUP DATABASE databaseName TO DISK = 'D:\BackupFileName.BAK' WITH DIFFERENTIAL

› Create a full backup to multiple disk files


This command uses the "DISK" option multiple times to write the backup to three equally sized smaller files instead
of one large file.
Example: BACKUP DATABASE databaseName TO DISK = 'C:\backupfileName.BAK',
DISK = 'D:\backupfileName.BAK',
DISK = 'E:\backupfileName.BAK'

› Create a full backup with a password


This command creates a backup with a password that will need to be supplied when restoring the database.
Example: BACKUP DATABASE databaseName TO DISK = 'D:\backupfileName3.BAK'
13
Identify and Resolve Database Performance Problems

WITH PASSWORD = 'Abc\123'

› Create a mirrored backup


This option allows you to create multiple copies of the backups, preferably to different locations.
Example: BACKUP DATABASE databaseName TO DISK = 'C:\backupFileName.BAK'
MIRROR TO DISK = 'D:\backupFileName_mirror.BAK' WITH FORMAT

› Specifying multiple options


This next example shows how you can use multiple options at the same time.
Example: BACKUP DATABASE databaseName TO DISK ='C:\backupFileName.BAK'MIRROR TO
DISK = 'D:\backupFileName_mirror.BAK' WITH FORMAT, STATS, PASSWORD = 'abc/123!'

 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

 Appends to the media


 Overwriting of the media
 A user Managed Backup
In order to select a proper backup type, a SQL Server administrator needs to understand the difference between the
major backup types clearly.
You should always have proper backup plan in place to protect your database from failures.
 Backup type
SQL Server has different types of backups
- Full Backup
- Incremental Backup
. Transaction Log backup
. Differential backup
. File and file group backup

Difference between: Full, Differential, and Incremental Backup

Type Definition Benefits Drawbacks


Full A complete backup of everything you want Restoration is fast, since The backing up process is

14
Identify and Resolve Database Performance Problems

you only need one set of slow.


Backup to backup.
backup data. High storage requirements.
Faster to create than a full
Restoration is slower than
The backup software looks at which files backup.
using a full backup.
have changed since you last did a full
Differential backup. Restoration is faster than
Creating a differential
Backup: For restoring all the data, you will only need using incremental backup.
backup is slower than
the last full backup, and the last differential
creating an incremental
backup. Not as much storage
backup.
needed as in a full backup.
The backup software creates copies of all
This method is the fastest Restoring from
the files, or parts of files that have changed
when creating a backup. incremental backups is the
Incrementa since previous backups of any type (full,
slowest because to restore
l Backup differential or incremental).
The least storage space is the data would require you
needed. to process the full backup

Note: The database must have full back up in order to take a differential backup, it only backups the changes since
last full backup.

Full/Differential/Transaction Log Backup using SQL Server Management Studio


. Right click on the database name
. Select Tasks > Backup
. Select backup type either "Full" or "Differential" or” Transaction Logl”
. Select the appropriate Backup Destination and click "OK"

File or File Groups Backup using SQL Server Management Studio

o Right click on the database name


o Select Tasks > Backup
o Select backup type either "Full" or "Differential"
o  Select Backup component as "Files and file groups"
o Select the appropriate file group
o Select the appropriate Backup Destination and click "OK"

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.

 Configuring and testing database performance


You need to configure the SQL server database to work with the application properly.
You can improve performance by considering the following items when configuring the database and log files.
1. Pre-allocating the space required for database files and log files will improve performance.
2. Allowing the log files to grow automatically is required to ensure that unexpected errors do not occur.
3. Placing the data files and log files on separate physical disk drives will improve performance substantially.
Make sure that these physical disk drives have enough free space to allow for database growth.
4. The database must be backed up regularly, and other database maintenance tasks must be performed from
time to time.
Database maintenance
After the application has been successfully installed, a database maintenance plan must be established.
Use the 'Maintenance Plan Wizard' to create the plan and schedule it. In the wizard, select these options:
 Check database integrity
 Shrink the database
 Reorganize the index
 Update statistics
 Do a full backup of the database

LO3. Tune database

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.

 Monitoring and tuning efficiency of structured query language


16
Identify and Resolve Database Performance Problems

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.

 Monitoring and measuring Performance of shared pool, blocks and buffers


 Check the SQL query optimization
Query optimization is a function of many relational database management systems. The query optimizer attempts
to determine the most efficient way to execute a given query by considering the possible query plans.
Indexing a column is a common way to optimize the search result.
SQL Tuning/SQL Optimization Techniques:
1) The SQL query becomes faster if you use the actual columns names in SELECT statement.
Example: SELECT Id, FirstName, LastName, Age, subject FROM student_details; Instead of:
SELECT * FROM student_details;
2) Use operator EXISTS, IN and table joins appropriately in your query.
a) IN is efficient when most of the filter criteria is in the sub-query, but Usually IN has the slowest performance.
b) EXISTS is efficient when most of the filter criteria is in the main query.
Example: Select * from product p
where EXISTS (select * from order_items o
where o.product_id = p.product_id)
Instead of:
Select * from product p
where product_id IN(select product_id from order_items

 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

3..1 shared pool


3..2 blocks
3..3 buffers
 Tune I/O
Reconfigure the database
Lock Management
Lock management ensures that one transaction does not see the effects of another until the first transaction is committed. A lock on data
limits operations on that data by other sessions.
There are different types of locks, and each permits and restricts operations. A shared lock permits other sessions to access the data, but
prevents modifications to that data. An exclusive lock permits modification but prevents other sessions from accessing the
data.
Lock contention can be a performance issue.
Lock granularity is a way of reducing lock contention.
The concept is that if one only needs to modify a single
row, then the entire table should not need to be
locked.

18

You might also like