Sap - sql2005 - Best Practices
Sap - sql2005 - Best Practices
Summary: This white paper describes best practices that customers, system
integrators, and partners can use to design and install more reliable, high availability
SAP implementations that deliver improved performance, scalability, and security by
using SQL Server 2005. The paper describes typical architectures, installation and
configuration, and performance monitoring and tuning. The paper also describes special
considerations for SAP BW and for 64-bit computing configurations.
Copyright
The information contained in this document represents the current view of Microsoft Corporation on the issues
discussed as of the date of publication. Because Microsoft must respond to changing market conditions, it
should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the
accuracy of any information presented after the date of publication.
This White Paper is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS,
IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS DOCUMENT.
Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under
copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or
transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or
for any purpose, without the express written permission of Microsoft Corporation.
Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights
covering subject matter in this document. Except as expressly provided in any written license agreement
from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks,
copyrights, or other intellectual property.
Unless otherwise noted, the example companies, organizations, products, domain names, e-mail addresses,
logos, people, places and events depicted herein are fictitious, and no association with any real company,
organization, product, domain name, email address, logo, person, place or event is intended or should be
inferred.
Microsoft®, Microsoft® SQL Server™, Microsoft® SQL Server™ 2005 Enterprise Edition, Microsoft® SQL
Server™ 2005 Express Edition, Microsoft® SQL Server™ 2005 (64-bit), Microsoft® SQL Server™ 2000,
Microsoft® SQL Server™ 7.0, Microsoft® SQL Server™ 6.0, Microsoft® Windows®, Microsoft® Windows
Server™, Microsoft® Windows Server™ 2003, Microsoft® Windows Server™ 2003 x64 Editions, Microsoft®
Windows Server™ 2000, Microsoft® Windows NT® 3.51, Microsoft® .NET, and Microsoft® Office System are
either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other
countries.
The names of actual companies and products mentioned herein may be the trademarks of their respective
owners.
Table of Contents
Executive Summary...........................................................................................1
Introduction......................................................................................................2
SAP Multi-Level Client Server Architecture........................................................5
Installation and Configuration........................................................................17
SQL Server 2005 Availability Features............................................................32
Performance Monitoring and Tuning...............................................................54
Special Considerations for SAP BW.................................................................70
64-Bit Computing Configurations....................................................................75
Solution Architecture......................................................................................80
Important SAP OSS Notes related to SQL Server.............................................96
Related Links and Online Resources................................................................97
Related Links and Online Resources......................................................................97
Executive Summary
Companies face numerous challenges managing and integrating information across
enterprise business processes. Customers need faster analysis and deeper business
insight to improve their decision making and to respond to changing business needs.
Companies frequently choose an Enterprise Resource Planning (ERP) solution to fulfill
these business requirements. The current leading ERP applications are the mySAP™
ERP and SAP® R/3® industry solutions from SAP AG.
mySAP ERP is comprised of a comprehensive range of products that empower the
enterprise with a flexible, end-to-end solution. mySAP solutions can increase business
productivity, enhance operational efficiency, and improve the Total Cost of Ownership
(TCO). mySAP solutions also offer the scalability needed to manage ever-increasing
workloads. mySAP solutions enable companies to pinpoint inefficiencies in current
business operations and to provide the resources needed to extend best practices to the
entire value chain.
A critical challenge in implementing a mySAP solution is in the selection of a data
platform that can deliver the advanced features and capabilities needed to support most
demanding workloads. Microsoft® SQL Server™ 2005 is the database of choice for
deploying more secure, reliable, highly available, high-performance, and scalable
mySAP installations.
SQL Server 2005 is an integrated data management and analysis solution. SQL Server
2005 enables SAP customers of varying sizes to share data across multiple platforms,
applications, and devices, while making it easier to connect to internal and external
systems. SQL Server 2005 high-availability features can minimize downtime in SAP
implementations. SQL Server 2005 improves productivity by making it easier to create
robust database extensions at a lower cost.
mySAP solutions running on SQL Server 2005 realize native performance
improvements. SQL Server 2005 contains built-in tools that simplify installation and
make it easier to deploy and manage SAP implementations. In addition, the SQL Server
2005 engine dynamically tunes database parameters automatically to respond to
changing usage characteristics.
This white paper describes best practices that customers, system integrators, and
partners can use to design, deploy, and operate high availability SAP implementations
with SQL Server 2005. This paper is provided to highlight that the common aspects of
SAP with SQL Server 2005 implementations reflect the specific characteristics of SAP
business applications.
The paper describes typical architectures, installation and configuration, and
performance monitoring and tuning including how to resolve common problems. The
paper also describes special considerations for SAP® Business Information Warehouse
(SAP BW) and for 64-bit computing configurations.
The paper assumes that the reader has at least a general understanding of mySAP ERP
solutions and Microsoft SQL Server database concepts and features. The SAP with SQL
Server 2005 best practices described in this white paper were developed using the
combined experiences of thousands of SAP customers worldwide.
Filename: 544804500.doc 2
Introduction
SAP AG is a recognized leader in providing collaborative business solutions for all types
of industries in major markets. SAP delivers powerful solutions to more than 26,150
customers in 96,400 installations with 12 million users in over 120 countries around the
world. SAP software offers distinct solutions that address the needs of small and mid-
size businesses and provides enterprise-scale solutions for global organizations.
SAP is the world's largest inter-enterprise software company and the world's third-
largest independent software supplier overall. Today, SAP employs more than 32,000
people in 50 countries. With enhanced collaboration provided by more than 1,500
partners, SAP professionals are positioned to provide high-level customer support and
services.
SAP industry solutions offer multi-platform support for business processes in more than
25 distinct industries including high technology, retail, public sector, and financial
services. mySAP ERP products can optimize business processes and improve
collaboration and integration across the extended enterprise.
mySAP ERP solutions use SAP NetWeaver™ as its comprehensive integration and
application platform. SAP NetWeaver works with existing IT infrastructures to enable
and manage change.
1
As of the third quarter of 2005.
2
The SAP/Microsoft joint development on product Duet.
2
Filename: 544804500.doc 3
by a factor of three or greater. When SQL Server 2005 is licensed through SAP and
is used for one application only, even greater savings can be realized.
Allows for scalability using standard commodity hardware. SQL Server 2005
is highly scalable and can allow for future growth using standard commodity servers
and storage. In addition, SQL Server 2005 takes advantage of some of the latest
hardware architectures. mySAP on SQL Server 2005 can now run workload levels on
four-processor commodity servers that, only four years ago, would have required a
32-processor server and a one-million dollar investment.
Offers the most compelling TCO. SQL Server offers the best TCO for SAP
implementations including lower management costs. Meta research concluded that
Windows offers two to three times better TCO than other enterprise platforms when
used in ERP scenarios3.
3
For more information, see “Microsoft – SAP Customer Information Center” at http://microsoft-sap.com/
4
For more information, see “Microsoft SQL Server 2005” at
http://www.microsoft.com/sql/2005/productinfo/overview.mspx
5
For more information, see “What's New in SQL Server 2005” at
http://www.microsoft.com/sql/2005/productinfo/overview.mspx#ECAA
4
Filename: 544804500.doc 5
6
For more information, see “Microsoft – SAP Customer Information Center” at
http://www.microsoft-sap.com/technology.aspx
Filename: 544804500.doc 6
HTML/SOAP WebServices
WebService
GUI WebGUI GUI RFC WebGUI GUI
Client sClient
Client
Database Server
SAP Servers
On the left, the SAP
Application Servers
sample shows examples
of instances for one R/3
system that use multiple
6
Filename: 544804500.doc 7
hardware servers. Some of the servers are running more than one SAP NetWeaver
Application Server instance.
A SAP system can contain dozens of NetWeaver Application Server instances running on
multiple servers. All of those instances of one system would work against one database.
The SAP NetWeaver Application Server User tier (also called the Presentation layer)
connects to the SAP NetWeaver Application Server Layer through the HyperText
Transfer Protocol (HTTP)/ Simple Object Access Protocol (SOAP), Web Services, Remote
Function Calls (RFC), or the proprietary Diag interfaces. The User tier is handled by so
called Dialog processes, which are dedicated to user interaction on the SAP application
server.
The SAP NetWeaver Application Server Layer contains the following logical components:
Virtual machines (ABAP and JAVA). The ABAP virtual machine (VM) is the heart
of SAP NetWeaver Application Server. Nearly all business report logic runs through
the ABAP VM. The Java VM is also used to process business logic, especially by
newer generations of SAP products like SAP Enterprise Portals and SAP XI.
Dispatcher (Queue Manager). The Dispatcher accepts requests coming from
different types of interfaces. The Dispatcher queues and distributes requests to
other SAP processes. The Dispatcher maintains communication with Presentation
tier layer.
Filename: 544804500.doc 8
The first time a request from the Presentation tier is made to SAP NetWeaver
Application Server, it is assigned to the Dispatcher process of a particular instance.
The Dispatcher process locates a free process in the instance with the requested
functionality. All of the different processes in one instance communicate with the
Dispatcher process.
Central services. Central services include Batch Scheduling, Memory Services, and
Enqueue Services.
Data persistence layer. Each VM has a data persistence layer that operates on
different schemas within the SAP database. Shared transactions (database
transactions) cannot be performed between the ABAP and Java VMs.
Message server. This server is the communication port for the SAP CI. The
message server handles all communication with other instances within the same
system. It also handles the initial communication to establish a client session with
the Dispatcher of a particular instance.
Be aware that the SAP ABAP stack and the SAP JAVA stack of the SAP Netweaver
Application Server are installable separately. Means during installation it can be decided
whether both or only one of the stack should be installed.
For more information, see “SAP NetWeaver: Providing the Foundation to Enable and
Manage Change” at:
http://www.sap.com/solutions/netweaver/index.epx
8
Filename: 544804500.doc 9
Server Layer system-wide. This avoids extensive locking on the database level
which could harm concurrency severely. The Enqueue process keeps the database
from being flooded with locks and blocks objects not yet released. It is worth to
note that the level of locking of the Enqueue is on Object basis. Such an object
locked could translate into many database rows in different database tables.
Spool process. This process enables print services for a SAP system. The process
sends a print request to the Windows spool manager.
Message server process. This process allows for communication between the
different NetWeaver Application Server instances within one SAP system. The
message server runs on the SAP CI and as well is a single point of failure
Gateway process. This process is responsible for external communication between
NetWeaver Application Servers.
SAP Process
Overview
On the left, the sample
lists different processes in
one SAP instance of a
SAP system running
multiple instances. The
sample does not show
the dispatcher, message
server, or gateway
process.
One specific SAP
NetWeaver Application
Server instance
represents a collection of
processes. The
NetWeaver Application
Server Layer can be
distributed over several servers to perform processes. In the commodity server space it
is common to run one SAP application server instance per server. On bigger hardware
one can find configurations with multiple SAP application instances on one server.
Different SAP application instances of SAP NetWeaver Application Server can be
configured differently based on the user or job assignments to those instances.
SAP NetWeaver Application Server instances can be configured to enable only one or
two types of processes or nearly all types of processes. The specific configuration
depends on the size of the SAP system and on the available hardware.
login. If this is the case, the user will get assigned to a specific SAP application instance
based on such an assignment and eventually workload on different application instances
if the assignment defined a group of application instances. If there is no special
assignment defined, the message server will assign the user to an application instance
based on workload consideration. The login request will then be transferred to the
dispatcher process of that application instance. The dispatcher will now assign the login
request to a free dialog process within its application instance. After a successful login,
the user will remain within the boundary of this SAP application instance. A transfer to
another instance is not possible.
After the successful login, the user now starts to work by calling a SAP Transaction like
‘Creating a customer order’. Such a request now goes directly from the Graphical user
Interface of the user to the dispatcher of the SAP application instance. The dispatcher
will check for a free dialog process and if found, will assign the request to that free
dialog process. As soon as the request is completed, the user context is rolled out of
the dialog process again, so that the process can be used to server requests from other
users. Means there is no fixed assignment of a SAP user to a process within a SAP
instance, but only a fixed assignment to a SAP instance. The dispatcher within the SAP
instance balances incoming requests of logged in users and active requests on the
process resources available. If there are no processes of the type required available, a
queue in the dispatcher will build up.
10
Filename: 544804500.doc 11
instance. A SAP process can map segments of the Memory Mapped File into the
particular SAP process. Segments mapped into one process can not be accessed by
another process of SAP. The advantage of the Memory Mapped File is that its size is
limited by the real memory plus the size of the pagefile and not by the Virtual Address
Space of the particular platform. However there is a slight disadvantage with this
method of realizing SAP Extended Memory. When a user context gets rolled out of a
SAP process again after the request’s execution finished, the SAP process will unmap
the memory segments again it ‘borrowed’ from the SAP Extended Memory. For the
Windows Memory Management this unmap operation leaves memory segments which
got changed without associated process. These two facts are reason for the Windows
Memory Management to page out these memory segments preventively to the Windows
Pagefile as long as there is CPU available. This leads to the fact that one will observe a
very high rate of page-out operations towards the Windows Pagefile, running a SAP
ABAP application instance. The higher the workload, the higher the page-out rate will
be. In extreme cases it could be as high as writing a constant stream of 20MB/sec to
the Windows Pagefile. However do not get to wrong conclusions based on this fact. The
page-out rate in such cases itself does not tell anything about experiencing a situation
of memory pressure. In order to evaluate whether there is memory pressure, one
needs to evaluate the page-in rate from Windows Pagefile. Only if the page-in rate is
high as well, one could be suspicious of memory pressure.
A fourth very big chunk of memory allocated by a SAP ABAP instance will be the so
called Program Buffer, caching pre-compiled ABAP reports instead of steadily re-reading
those from the database. Usually this part of buffer has a size of 500+MB. This buffer is
realized as shared memory which can be accessed by each of the SAP processes within
an instance
Besides the 4 different memory areas described, there is over another dozen more or
less smaller shared memory areas a SAP ABAP application instance creates and which
are shared amongst the processes of such an instance. None of these memory areas
will be shared between different SAP Instances.
Application Se rve r
mySAP W
Work
ork Process
Database Interfaces
(DBSL)
SQ L OLE DB
The first connection SAP established is used for modification of data and in rare cases
where a read-committed isolation level is needed for reading some data. On the second
connection, SAP reads most of the data on an uncommitted read isolation level (Dirty
Read). SAP introduced this principle in 1993/94 for all databases but Oracle. There is no
disadvantage doing so since the SAP Netweaver Application Server is designed to deal
with eventual Phantom Records or other anomalies which can be introduced by reading
uncommitted data. So imagine a SAP system with 10 application server instances on 10
different small servers. Every one of the application server instances is configured with
an average of 30 SAP processes. In such a case it means that the SAP application layer
of such a system will open 10 X 30 X 2 = 600 connections to SQL Server 2005
12
Filename: 544804500.doc 13
When accessing a SAP database with SQL Server 2005 query tools, the
setuser <SID>
command must be executed before data can be read.
Because the SAP customer can install more than one schema in one SAP database,
ensure that the schema is correct. Most schemas have a set of objects that are
named in the same manner in both schemas.
The preceding SAP security considerations involve the last two releases of the SAP
NetWeaver Application Server, which are supported by SQL Server 2005. In older
releases, a SAP database could contain only one schema owned by the database role
‘dbo’.
7
The SAP OSS Notes are only available to registered customers of SAP AG.
14
Filename: 544804500.doc 15
8
The SAP Product Support Matrix is only available to registered customers of SAP AG.
Filename: 544804500.doc 16
Uninstall SQL Server 2000 and install SQL Server 2005. Then attach the SQL Server
2000 SAP databases to SQL Server 2005.
Install SQL Server 2005 in the same location without uninstalling SQL Server 2000.
As already mentioned above, before uninstalling the SQL Server 2000 instance, verify
that the SAP database is on code page cp850_BIN2 . See SAP OSS Note 600027 for
more information.
Once the SQL Server 2000 database is attached to SQL Server 2005, a special version
of SAP SAPINST needs to be run to adapt the database to some of the SQL Server 2005
features that are used by SAP. See SAP OSS Note 799058 for more information.
There is no SAP related direct upgrade from SQL Server 7.0 to SQL Server 2005 with
SAP products. For such systems an upgrade over SQL Server 2000 is necessary.
16
Filename: 544804500.doc 17
run dbcc indexdefrag as online data reorganization tool on several of the big
tables. Other databases might have some online reorganization tools as well.
Split large tables into multiple jobs. However be careful with the ‘where clauses’
SAP tools may define for each of the export parts. These ‘where clause’s may
not line up with existing indexes, so that each of the export jobs would perform
a full table scan. Something one wanted to avoid with the step of splitting the
export in multiple parts. Therefore adjust the ‘where clause’ for each of the
export statements manually if they do not align with existing indexes on that
table.
For very large implementations, the database can grow from 20 to 30 GB each
month.
Even if SAP archiving is used, in most of the customer systems one could observe a
steady and consistent growth rate in database size over time. Therefore it does not
matter if a database of 2TB volume might suddenly encounter 800GB or more free
space after severe data archiving. SQL Server does not encounter any disadvantage
having such huge freespace. Since SQL Server backups only contain used blocks, there
also are no increased efforts in administrating in case of having larger portions of
unused space in the database. This unused space should not lead to the desire to shrink
the SAP database. Besides the fact that shrinking the database could be a longer
process since data may need to be moved, it also can result in extents where the logical
and physical order are opposite. Something which disturbed some sophisticated storage
backend logic in the past. It also is not recommended at all using the option
‘autoshrink’ for a SAP database.
18
Filename: 544804500.doc 19
typically increases in stages, indicating that a much larger database server might be
required in the future.
Evaluating disk configurations. Evaluate the available storage hardware
including the number of disk arrays and partitions, and the amount of available
storage space on disk arrays.
Estimating database growth. Consider the estimated database growth during
production. In order to stay flexible in disk configurations, avoid using very large
data files. Very large data files can create problems in handling, for example, setting
up sandbox systems, copying, and so on.
Evaluating non-production environments. Keep in mind that each SAP
production system is supported by test and development systems. This means the
test system needs to be synchronized with the production database periodically. A
sandbox system that is based on the SAP production system might also be required.
Increasing the number of data files. In some cases the infrastructure might
require more than three data files with more CPU cores available. However, too
many data files often increase monitoring requirements. The use of a large number
of data files should be avoided.
Setting autogrowth. Using autogrowth is highly recommended for all data files,
even if the autogrowth of a data file limits the proportional fill functionality of SQL
Server over the data files. It is better to have some uneven distributed data than to
have SAP components such as mySAP stop running. When automatic growth is
used, set each data file to a 10 percent growth allowance.
Proportional Fill
On the left, the sample demonstrates
the proportional fill feature, which is
used to spread the data between the
data files according to each file’s
available free space. The considerations
for using the proportional fill include:
Extending the data file size. As
volume increases, manually extend
the size of the data files by the
same amount. Assume that each file
was created to the same size.
Proportionally fill the data files.
When data is inserted into the
database, the data files are filled
proportionally using the free space
in each data file.
If the data files were created to the same size, SQL Server 2005 distributes the data
of each table evenly over the existing files. This makes the read/write workload
even, simplifies placing the data files over a storage backend, and avoids hot spots
on specific disks.
Recalculating the proportional fill factor. Periodically, SQL Server re-calculates
the proportional fill factor for each file based on the available free space. When one
of the data files becomes full, the proportional fill goes out of balance. In this case,
Filename: 544804500.doc 20
it fills the other files, grows only one of the files, and fills this file. Then it grows the
next file, and so on.
Setting autogrowth. Avoid situations where automatic growth is set by manually
increasing the size of the data files proportionally in advance. Although the data files
can be manually manipulated proactively, leave autogrowth on as a safety measure
in case of an emergency such as when the database runs full.
20
Filename: 544804500.doc 21
tempdb Considerations
Tempdb is the temporary database for SQL Server 2005. Tempdb is used by queries to
execute large join, sort, and group operations when the SQL Server buffer pool is
cannot provide enough memory. For SQL Server 2005 tempdb is also heavily used by
base features including Snapshot Isolation Level, which is used for online index
maintenance or to assemble data that is pushed into text/image or
varchar(max)/varbinary(max) datatype columns.
SAP products such as mySAP™ ERP or mySAP CRM, and SAP BW each stress tempdb in
different ways and have different performance requirements. Basically, the usage of
tempdb differs according to the type of workload. The two types of workloads are an
online transaction workload as in the case of mySAP ™ ERP or CRM, and mySAP
Enterprise Portal (mySAP EP) and an Online Analytical Processing (OLAP) oriented
workload such as those created by SAP BW:
Online transaction type workloads (OLTP). mySAP products with online
transaction workloads including mySAP CRM and mySAP ERP, use tempdb
infrequently for larger join operations, aggregation, and smaller sorts. tempdb
typically does not load or sort gigabytes of data. Overall system performance is less
dependent on throughput capabilities of tempdb. For installation, set the tempdb
space from 1 to 2 GB with six to eight spindles. For SAN storage, tempdb can share
space with the tempdb log files.
OLAP-oriented workloads. For SAP BW, tempdb can expand to larger sizes. For
example, join operations, especially those that fully scan the fact table of a cube,
can use gigabytes of space to store temporary result sets, large sorts, or hash
probes or to build aggregates. In these cases, tempdb is used to perform most of
the work since the memory space usually is not sufficient to process gigabytes of
data. In extreme cases, when the whole fact table is read in order to build an
aggregate, tempdb can grow to the size of the fact table, up to several hundred
gigabytes.
SAP BW tempdb performance. For SAP BW, tempdb I/O performance can
become a major bottleneck when executing reporting queries that use the fact table
or perform aggregation. In order to prevent bottlenecks, set the tempdb size to 1.5
times the space of the largest fact table. Manage tempdb strictly like a normal SAP
BW database. Eventually use one data file of tempdb on the same partition with
each data file of the SAP BW database. In this case, the tempdb space should
provide fast read/write performance. In addition, do not place tempdb data files
together on disks that contain the transaction logs of any databases.
instance is easy administration. The trade-off is that different SAP systems must share
the resources of one SQL Server 2005 instance including data cache, processors, and
tempdb. The resources used by each instance can be restricted, although adding this
restriction entails more administration overhead.
In order to restrict resources taken by eventual different SQL Server instances on one
server, one can use the SQL Server configurations:
affinity mask
max server memory
Both of those configuration parameters are discussed later. The problem with managing
the CPU resource consumption of SQL server instances with ‘affinity mask’ can be:
The granularity of one CPU (as displayed by Windows task manager – Dual-Core
processor = 2 CPU, Hyperthreading = 2 CPUs) might not be fine enough
Setting affinity mask might be too strict and does not give enough flexibility for
the specific usage (think about a system used for an afternoon in a trainings
class).
For such cases it is recommendable to leverage Windows WSRM for CPU resource
restrictions of SQL Server. WSRM does provide more flexibility in granularity as well as
in throttling. E.g. WSRM will start throttling down the CPU consumption of an instance
to its defined limits, if the overall CPU consumption on the server goes beyond 75%.
However it is not recommended to use WSRM for restricting the memory consumption
of a SQL Server Instance. This better is done with ‘max server memory’ configuration of
SQL Server. About the usage of WSRM with SQL Server, please refer to:
http://www.microsoft.com/technet/prodtechnol/sql/2000/deploy/64bitconsolidation.ms
px
22
Filename: 544804500.doc 23
affinity mask
The affinity mask parameter defines the specific processors on which SQL Server
threads can execute. When SQL Server 2005 runs as the dedicated database server or
with a SAP application, the affinity mask parameter uses the default setting of 0.
The 0 setting permits SQL Server threads to execute on all processors. In most
situations, the 0 setting provides the best performance because it avoids trapping SQL
Server connections on a specific processor, while leaving capacity on other processors.
The 0 setting is used with dedicated database servers and SAP two-tier configurations.
One could use the affinity mask parameter in cases when multiple SQL Server instances
and a number of SAP instances run on consolidated hardware. For example:
When multiple instances of SQL Server run on a single server.
To assign each SQL Server instance to particular processes on the server.
The affinity mask parameter is represented as a binary pattern that is expressed by a
decimal number. The affinity mask parameter settings are shown in the following table.
affinity mask
First processor only 1
Second processor only 2
First and second processor only 3
First four processors 15
First eight processors 255
However there might be better possibilities than using affinity mask to address such a
consolidation scenario of running multiple SQL Server Instances. See here for more
information.
The affinity I/O mask parameter is defined according to the same conditions as the
affinity mask parameter. It is best to use the default setting of 0.
On the left, the sample shows that the affinity mask and affinity I/O mask parameters
are set to 0 (the default) in the Server Properties dialog box.
awe enabled
The awe enabled parameter is used to extend SQL Server Buffer pool beyond the virtual
address space on 32Bit for high-end database servers. Address Windowing Extensions
(AWE) should not be used with any of the 64-bit platforms. AWE administrated memory
only can be used for data pages. Caches and structures such as statement or procedure
cache, lock structures, and buffer headers will remain in the virtual address space and
will not use memory accessed over AWE functionality.
In order to use the awe enabled parameter, the /PAE option must be set in the
boot.ini file of the Windows operating system.
The user context used to start SQL Server requires local permissions to ‘lock pages
in memory’.
For SAP, the 3 GB virtual address space is typically used although some customer
scenarios only may require a 2 GB virtual address space. The 3 GB memory is
enabled by adding the /3gb option in the boot line in the boot.ini file.
In some cases, using AWE on 32-Bit servers with up to 16 GB of real memory a positive
customer experience for some SAP workloads can be achieved. However, using more
than 16 GB of memory on a 32-bit SQL Server 2005 platform under a SAP workload is
not recommended. If more than 16 GB of memory would be required, it is
recommended to move to a 64-bit computing platform. See the “64-Bit Computing
Configurations” section for more information.
For SAP to use up to 16 GB of real memory, set the max server memory parameter to a
fixed value of 14 to 15 GB maximum and assign the set working set size parameter to
0. During startup, SQL Server allocates the AWE portion of the memory immediately.
Note that the memory usage of the SQL Server process is not indicated correctly by the
Windows Server 2003 Task Manager. The footprint of the SQL Server process shows a
very low number of bytes that does not reflect reality.
However, the commit charge under the Performance tab of the Windows Server 2003
Task Manager indicates when a large amount of memory was allocated. The allocation
of AWE memory can extend the startup time of SQL Server to for about a minute.
lightweight pooling
The lightweight pooling parameter is not recommended in general because it results in
only minor performance improvements. This parameter is typically used for benchmark
workloads that are extremely uniform.
24
Filename: 544804500.doc 25
Note that in the past, activating lightweight pooling (set to 1) was recommended for
running a server based on the Unisys ES7000 architecture.
26
Filename: 544804500.doc 27
As a workaround, SQL Server can be forced to leave more virtual address space by
adding –gxxx, with xxx=number specifying MB – default =256 MB in SQL Server 2005,
as a start up parameter to define a value above 256 MB. This is not a problem in 64-bit
computing platforms.
priority boost
The priority boost parameter defines the priority of SQL Server processes. Having the
value set to 1 gives SQL Server processes a slightly higher priority. The current
recommendation is to set the priority boost parameter to 0, which leaves SQL Server
processes with a normal priority.
In the past, SAP and Microsoft have recommended having the priority boost parameter
set to 1. However, this recommendation changed recently to having the priority boost
parameter set to 0, due to situations where operating system network threads were
starved in favor of the SQL Server process, thereby causing failure situations and
transaction rollbacks.
In addition, due to improvements in SQL Server 2005 and Windows Server 2003, the
advantages formerly achieved by increasing the priority of SQL Server processes have
been minimized.
recovery interval
(min)
The recovery interval (min)
parameter is used to control the
checkpoint interval. SAP
recommends using the default
setting of 0. In customer scenarios,
using 0 causes a checkpoint interval
to occur every 30 to 60 seconds in
situations where no other event
triggered a checkpoint such as
Commit.
SQL Server checkpoint intervals are
extremely sensitive with disk
resources. SQL Server works to
avoid overloading the I/O during
checkpoint writes. In the past, there
have been no customer issues with I/O flooding caused by SQL Server checkpoints.
In contrast to competitor databases, the mySAP space does not require this value to be
adjusted in order to achieve better control of checkpoint effects.
28
Filename: 544804500.doc 29
servers. In addition, this parameter no longer has an effect on SQL Server 2005. At
present this parameter is used only to avoid setup application failures.
The same heap/index is referenced more than one time in a statement; the
locks on each instance of those are counted separately. So for example, in the
case of a self-join on a table t1, if each instance has 3000 locks within the
statement, it will not trigger lock escalation
The memory taken by lock resources > 40% of the non-AWE (32-bit) or regular
(64-bit) enabled memory when the locks configuration option is set to 0, the default
value. In this case, the lock memory is allocated dynamically as needed.
A scenario where one could see SQL Server to go for table level locks from the
beginning could be a query like:
update TABLE1 set PRICE=PRICE*1.1
Assuming that table1 would contain like 1 Mio rows, it is likely (dependent on some
other schema conditions) that SQL Server would try to start with a table lock executing
the query. If any other existing lock would conflict with the table level lock, the next
cheapest solution might be to acquire page locks. If that again could be hindered by
conflicting locks, the query will start with row level locks. However after having 5000
locks acquired on one heap or index, SQL Server will check again for escalating to a
table level lock.
Looking at such a scenario with the SAP deployed stored procedure sap_lock
one could find the following entries for a table lock in the first few column of the result
set:
Query executed under Table Lock
Tablename spid dbid IndId Type Resource Mode Status
---------------------------------------- ------ ------ ------ ---- ---------------
TABLE1 100 5 0 TAB X GRANT
A case where the same update statement is executed under page level locks the output
of the fist few columns of the sap_lock output could look like:
In this case, the table lock is IX indicating that lower granular X locks are held within
the table by the same session.
Output of the sap_lock where the update statement is executed using row level locks
would look like:
Tablename spid dbid IndId Type Resource Mode Status
---------------------------------------- ------ ------ ------ ---- ---------------
30
Filename: 544804500.doc 31
Again the IX locks on the table and page are indicating lower granular X locks on the
table and on the specific page, which in essence only can be row level locks.
Another typical example where SQL Server might try to use a higher granularity level
could be:
update TABLE1 with (UPDLOCK) set PRICE=PRICE*1.1
where STATUS = ‘NEW’
In this, the lock granularity SQL Server would like to start with is dependent on the fact
whether an index exists on the column STATUS and how big the expected result set
would be. Like before, assuming table TABLE1 would have 1 Mio rows and due to the
absence of an index on the column VALID, the whole table would need to be scanned in
order to locate the rows fitting the predicate of the Where clause. Therefore it is highly
likely that SQL Server would try to start with a different granularity than row level
locking. Dependent on competing conflicting locks, the granularity is decided then.
In both cases an index on the column STATUS would help to increase the chances of
row level locks, under the assumption that the majority of values in column STATUS do
have different values than ‘NEW’.
' IsPageLockDisallowed')
To suppress lock escalations to table locks taking place, one has two possibilities:
TraceFlag-1211: It disables lock escalation at the current threshold (5000) on a per
index/heap per statement basis. When this trace flag is in effect, the locks are never
escalated. It also instructs SQL Sever to ignore the memory acquired by the lock
manager up to a maximum statically allocated lock memory or 60% of non-AWE(32-
bit)/regular(64-bit) of the dynamically allocated memory. At this time an out of lock
memory error is generated. This can potentially be damaging as a misbehaving
application can exhaust SQL Server memory by acquiring large number of locks.
This, in the worst case, can stall the Server or degrade its performance to an
unacceptable level. For these reasons, a caution must be exercised when using this
trace flag
TraceFlag-1224: This trace flag is similar to trace flag 1211 with one key difference.
It enables lock escalation when lock manager acquires 40% of the statically
allocated memory or (40%) non-AWE(32-bit)/regular(64-bit) dynamically allocated
memory. Additionally, if this memory cannot be allocated due to other components
taking up more memory, the lock escalation can be triggered earlier. SQL Server
will generate an out of memory error when memory allocated to lock manager
exceeds the statically allocated memory or 60% of non-AWE(32-bit)/regular
memory for dynamic allocation.
If both trace flags (1211 and 1224) are set at the same time, the trace flag 1211 takes
precedence. You can use dbcc tracestatus (-1) command to find the status of all trace
flags enabled in SQL Server.
Are there big chances ever hitting situation where a page or table lock will block other
concurrent accesses in the daily productive live with SAP products? With SAP standard
delivered coding the only situations observed so far was around the table DDLOG
deleting massive amount of rows in one delete statement. In some cases one could
observe other than row level locks in customer written ABAP programs where
customers tried to change massive amounts of rows with one statement by having
hardly an restrictions in where clauses. Another occasion where it could be observed
where customer written reports performing updates where the where clause of the
update statement was not sufficiently supported by existing and SAP deployed indices
on the affected tables.
Due to the fact that SAP reads dirty most of the time, the number of locks held by SAP
applications usually is very low in the hundreds and few thousands. Also given the fact
that the buffer sizes for SQL Server running under SAP workloads are going into the
GigaBytes, an escalation because of lock structures occupying 40% of the buffer pool
never has been observed.
32
Filename: 544804500.doc 33
redundancy or other features first should be explored and maximized, before one thinks
about other high availability features involving secondary database servers.
This section should not elaborate deeper into disk level redundancy, nor should the
usual RAID concepts be explained here. As described in different configurations here in
this whitepaper, the minimum RAID level of any part of SAP user database should be
RAID-5 at least, preferably even mirrored. Having not the slightest redundancy
measure on disk level simply is not acceptable. More on different RAID levels can be
found on:
http://en.wikipedia.org/wiki/RAID1#Standard_RAID_levels
or on this whitepaper which also explains some other storage features of SQL Server
applicable for SAP. Please note that not all described measure in this whitepaper are
applicable for databases related to SAP applications:
http://www.microsoft.com/technet/prodtechnol/sql/2005/physdbstor.mspx
Besides RAID levels on the storage steps like using multiple Host or Fiber Adapter cards
which can failover work are steps to take in high-end servers. Other than that SQL
Server 2005 does offer a new feature for proving on physical consistency of pages.
Checksum on Pages
Additionally SQL Server does provide different checks so that pages written to storage
do not get corrupted. So far these checks of SQL Server are done reading those pages
from storage. The level of checks are configurable on a per database level. So far SQL
Server only checked whether chunks of 512Bytes within one page got written at the
same time. This was the so called ‘torn page detection’. With SQL Server 2005 a more
strict check on physical consistency got introduced on a page level. This is to build a
checksum on a page before writing it to the storage, saving that checksum in the page
header and verify the checksum during reading the page next time by re-calculating
and comparing the checksum saved on the page with the one being calculated.
Filename: 544804500.doc 34
Using checksum compared to ‘torn page detection’ which was used so far, can increase
resource consumption slightly. Dependent on the I/O volume, an increase of up to 5%
CPU resource consumption can be observed. Be aware that databases which are getting
upgrades from SQL Server 2000, restored from a SQL Server 2000 or SQL Server 2000
databases getting attached remain on the level those have been before (usually torn
page detection). Means ‘checksum’ checks are not activated. However databases which
get created under SQL Server 2005 will automatically have ‘checksum’ checks enabled.
Enabling ‘checksum’ on a database which got updated from SQL Server 2000 will
trigger checksumming pages which get written newly only. There is no process
checksumming all the pages which are contained in the database in a background
manner. Means protection by checksum will hardly get to 100% in the immediate time
frame. Executing a backup against pages with torn page or checksum data, the backup
code does check on torn pages or checksum before writing the page to the backup
device.
Online Backups
In SQL Server 2005, online backups perform only one data backup at a time for each
database. The backup and restore functionality includes FullText catalogs. The point in
time which is stored by the backup on the backup medium is NOT the point in time
when the backup started, but is a point in time which is very close to the end of the
backup. This is possible due to the fact that the online backup is just going sequentially
through the database in one or multiple threads and just reads the data as it is at that
point in time on disk. Additionally the changes documented in the transaction log during
the time the online backup ran, are added to the backup. This makes the online backup
extremely fast, because changes happening meanwhile are not interfering with the
backup. Restoring such a backup the extents stored on disk will be copied to the
database as copied to the backup medium. After that step is done, the change records
which are stored on the medium as well get applied to the database. From a load
perspective, a backup hardly consumes CPU, but can create substantial I/O load.
Changes and improvements applicable for SAP related databases in this area made in
SQL Server 2005 are:
Transaction log backup execution. The restriction of not being able to execute a
Transaction Log backup while an Online Backup was in execution. This limitation is
removed with SQL Server 2005 and increases the safety level on the customer side
and the ability to restore to a point-in-time, even to the timeframe during which the
online backup ran.
Single page restoration with the database online. SQL Server 2005 can restore
single pages from online and transaction log backups while the rest of the database
34
Filename: 544804500.doc 35
What did not get really improved in these processes is the progress indication of each of
those 3 phases. The first phase of analysis usually is pretty accurate. However in the
second and third phase extreme cases sometimes can be seen where estimations of
hours for Redo are written into SQL Server Errorlog. In such a case the best thing to do
is to use Windows Perfmon and check the read rate on the partition the transaction log
resides on. Then take the size of the transaction log and divide it by the read rate. That
at least gives an accurate worst case estimation for the assumption that the transaction
log was completely filled up at the time the incident happened.
In the small area of a few hundred Gigabyte or up into the lower Terabyte area,
it can be feasible to perform SQL Server Online backups against direct attached
tape libraries. At this point in time (September 2006), there are tapes on the
market which store 400GB uncompressed data per cartridge. However the SAP
landscape does contain more than one productive SAP product usually and also
does contain test and development systems. Therefore the number of tape
drives or libraries might become increasingly high and eventually a serious
investment cost. Performance characteristics of SQL Server Online backup are
pretty much throttled only by disk throughput and by possible throughput for the
direct attached tape arrays. Means the better the read I/O throughput and the
better the possible write throughput to the tapes, the faster the backup will
perform. There hardly is any CPU involved. There hardly is any synchronization
with other SQL Server activity necessary for the backup. Therefore most of the
resources leveraged during SQL Server Online backup in such a configuration is
I/O bandwidth. It is recommendable to attach the local tape drive/library with
separate controller cards in order to maximize throughput.
In the more high-end area of volumes well into Terabytes, the investment into
local attached tape libraries for many of the customers is too expensive or does
simply take too long to execute. Especially the run time of a backup can be
reduced dramatically using SQL Server Snapshot backup which can be leveraged
by SAN/NAS storage vendors. In such a case, the hardware vendor’s software
interacts with SQL Server in order to tell SQL Server that a Snapshot is planned.
SQL Server will freeze all write activity to the database, which should be
targeted and gives control back to the calling software of the hardware vendor.
Then the SAN/NAS storage vendor is performing the activities to duplicate or to
prepare the duplication of the database. Ideally this process takes less than one
minute. The hardware vendor’s software then will hand back control to SQL
Server. SQL Server at this point will open write I/O to the database again and
will note a snapshot backup being executed successfully. Dependent on the
SAN/NAS hardware vendor one does have a snapshot backup available at that
point in time which is a complete clone (means eating up as many disk space as
the origin) or at least a process running creating such a clone over the next few
hours. If such a clone exists, one can pull this clone to tape devices which are
either local attached or centralized. But the phase of getting the backup to
tapes would be a less critical one from timing perspective.
Other customers of mid ranged to high volumes into the Terabyte area are
executing SQL Server online Backup against direct attached disk devices. These
might be less expensive devices or those might be located on SAN/NAS storage
as well. After the backup succeeded the backup is either pulled to local attached
tapes or to centralized tape devices. The success of this method is solely
dependent on disk I/O throughput and the configuration of the storage devices.
It for sure is not advisable to use the partitions as backup destinations which
contain the SQL Server data files which are getting backed up. This would
overload those partitions by the extreme contrary workload of reading and
writing. It also proved to be best practice to even use totally separate spindles
for the partitions containing the data files and work as destination for the
backup. E.g. to achieve a backup throughput of 1TB/h, one need to sustain
around 277MB/sec on read I/O and 277MB/sec on write I/O on the other side. It
36
Filename: 544804500.doc 37
Validating a backup
The fact that a backup either of the database or the transaction log is written to tape or
another device and gets stored there for weeks to come, does not guarantee at all that
such a backup is restorable. In the past there always were cases where tapes figured
out not to be readable anymore. Or in case tapes were readable, content on the tape
was damaged and hence backups failed to restore. Some of these cases led to
customers loosing weeks of data. Therefore just storing backup sets in a vault is not
good enough. One of the most simple solutions independent on the way the backup
infrastructure looks is to restore the backup against a sandbox system in a regular
manner. The sandbox hardware does not need to be a server of the most modern kind.
The storage also does not need to be the newest and best. The question to be answered
by such a periodic task is whether the backup residing on tape or some other device
can be restored. Time to restore is not the primary goal. After the backup got
successfully restored one as well could use the database to run a physical consistency
check on the restored database. Again, time is not the issue. It doesn’t matter if the
check takes two days for a database in the Terabytes. Another possibility would be to
execute a ‘restore verifyonly’ towards the Online Backup (not possible in all the backup
methods named above). In opposite to SQL Server 2000, SQL Server 2005 did enhance
the checks of verifyonly to a point where page IDs get checked, so that one gets a high
confidence in the fact that the page formats still are fine on the backup. Using
verifyonly to check on the backup, it could make sense to use a new backup option of
SQL Server 2005. The option is called ‘Checksum’ and will create a checksum over the
backup streams. These streams will be verified while performing a ‘restore verifyonly’.
Hence one can make sure that what was written to the backup device(s) got stored the
same way.
Despite all the checks on could do, the exercise of periodically restoring a backup also
as an exercise for personal still is something one should target to establish as best
practices.
Filename: 544804500.doc 38
Media Reliability
SQL Server 2005 delivers a number of media reliability improvements including:
Backup with multiple destinations. With SQL Server 2005, a backup can write to
up to four different destinations. Multiple sets of tapes can be written for the same
backup. When redundant backups are written, the tapes from each destination set
are interchangeable with the same tape in the other sets. For example, if a tape
from one destination set is lost, the same tape from one of the other sets can be
used instead.
Verification of page restores. Verifyonly like mentioned above investigates the
physical structure of a page. The linkage between the pages and the accuracy of the
allocation pages is not checked.
Restore sequence reliability. The SQL Server 2005 restore sequence continues
despite physical inconsistency in order to give customers an opportunity to repair
errors. The restore sequence continues as far as possible before the database needs
to be repaired.
Log Shipping
SQL Server 2005 supports log shipping to feed transaction logs from one database to
another on a constant basis. Continually backing up the transaction logs from a primary
database, and then copying and restoring the logs to a secondary database, keeps the
databases synchronized. This provides a backup server for disaster recovery and also
offers a means to offload query processing from the primary server to a read-only
destination server.
Log shipping is recommended for use in a variety of scenarios. Some customers are
using it across geographically distant data centers as part of their disaster recovery
configuration. Note that with log shipping there is no automatic failover and committed
transactions can be lost. This is dependent on the frequency with which transaction log
backups are performed.
Advantages of SQL Server Log shipping however are:
38
Filename: 544804500.doc 39
For SQL Server 2005 the setup in a MSCS environment did change. Like with the SQL
Server setup of SQL Server 2000 IA64, a promotion of a non-clustered node to a
clustered node is not possible anymore. This affects the way how SAP systems needs to
be installed in a different order than before. Please check the latest OSS notes in
regards to the way of installing a SAP system against SQL server 2000 IA64 (like OSS
note #387879) or SQL Server 2005 in an MSCS environment. For installations against
SQL Server 2005 also download the latest SAP Installation Master DVDs from the SAP
Service Market Place. SAP Installation documentation of the most recent releases
should reflect the changed way of in stalling.
Another change in SQL Server 2005 setup is to support Mountpoints in a MSCS
environment.
Advantages MSCS setups offer are:
Automatic failover initiated when hardware of SQL Server instance becomes
unresponsive.
However one of the disadvantages of MSCS setups is that all the nodes cooperating are
working against one database image. Means there is no way to compensate for physical
consistency problems which get introduced within the I/O path due to failing
components.
Database Mirroring
Database mirroring is a new feature which became general available for production
usage with SQL Server 2005 Service Pack1 (SP1).
Filename: 544804500.doc 40
Comparing the features of the different configurations of Database Mirroring with Log
Shipping and MSCS functionality, one could state the following:
Like Log shipping Database Mirroring does provide the possibility of two
separated database images. However unlike Log Shipping, Database Mirroring
can be setup in a way that no committed transactions are lost.
Like MSCS Database Mirroring does provide dependent on the setup an
automatic failover for applications like SAP ABAP Application server.
Database Mirroring can also provide a database image close to production with
non-measurable performance impact.
One restriction of Database Mirroring one has to be aware of is the fact that only one
destination can be targeted. The granularity of mirroring is a single database. However
more than one databases of one SQL Server instance can be mirrored.
The system administrators are able to manually force a failover. It also is possible to
suspend active mirroring in order to perform maintenance on one of the servers. As
long as database mirroring is suspended, the transaction log records are collected in the
transaction log of the active database. Even transaction log backups will not delete
these records. Means the time mirroring stays suspended should be limited. After
database mirroring does get resumed, it goes into a phase of synchronization. In this
phase all the changes are transmitted to the mirror server additional to the current
changes which queue up at the end of the data to be synchronized. Means the volume
of data changed during the suspended period and the network bandwidth will decide on
the time it takes to synchronize.
In the following chapters the three mirroring configurations for use with the two SAP
Application server architectures and the setup of the SAP components on database
mirroring are discussed. Database Mirroring will not be described in all its details in this
whitepaper. Therefore it is recommended to read more detailed descriptions before
implementing database mirroring. For a very detailed description of SQL Server 2005
40
Filename: 544804500.doc 41
Database Mirroring and more technical details, we would recommend reading the
following articles:
http://www.microsoft.com/technet/prodtechnol/sql/2005/dbmirror.mspx
and
http://www.microsoft.com/technet/prodtechnol/sql/2005/technologies/dbm_best_pract.
mspx
Asynchronous Mirroring
Configuring Database Mirroring in asynchronous mode, the transaction log records are
sent asynchronously to the mirrored server. The principal database server does not wait
for the mirror server to acknowledge the receipt of the transaction log records before
confirming the commit to the SAP application. As a result a long latency in transmission
of the records and the confirmation will not affect the response times on the principal
server.
Asynchronous mirroring does not guarantee that all transactions committed on the
principal server will be saved to the mirrored server. In case of a crash of the principal
server there is a chance that the last few committed transactions on the principal server
can get lost. Therefore it is not possible with asynchronous mirroring, to have automatic
failover. A failover to the mirror server needs to be initiated manually in this
configuration. Asynchronous mirroring can be used in disaster recovery scenarios when:
When small loss of the last few transaction is tolerable
When the database is mirrored to a remote site across over longer distances,
which would introduce too long latency times.
Currently, most SAP customers use log shipping under similar conditions. Using
asynchronous mirroring instead is an effective alternative that improves transactional
consistency and, most importantly, provides a mirrored image of the database that is
closer to the principal image of the database. The main disadvantage compared to log
shipping is that changes on the principle side are getting propagated within split
seconds and will get applied to the mirror database. Therefore using database mirroring
human errors cannot be compensated by delaying the restore of transaction log records
like this is possible with SQL Server log Shipping.
Theoretically a manual failover could be initiated at any point in time. SAP processes
would reconnect to the mirror server after the failover completed. But all open and
running transactions would be rolled back. Therefore if the manual failover takes place
controlled and planned, it is recommendable to shut down the SAP ABAP application
stack and manually force the failover to the mirror and then restart the SAP
applications.
Synchronous Mirroring
For synchronous mirroring, the primary server confirms the transaction to the SAP
application only after acknowledgement from the mirrored server is received. This
configuration offers two-phased transactional consistency. Instead of having only a
single copy of the data on shared storage, there are two separate and consistent
Filename: 544804500.doc 42
copies. This database mirroring configuration will result in a performance impact on the
principal database server and the SAP application. In the way how the SAP ABAP
Application Server based Logic is executed mainly using asynchronous database
updates, it is expected that the performance impact mainly affects the SAP update
processes and eventual SAP batch processes. For the Dialog part of the SAP Business
Logic there hardly should be an impact. Whereas Java based SAP logic might be
affected across the board since there is no separation in processes or threads
performing database reading and writing. The performance impact mainly results from
the fact that the principle server will wait on the Mirror server to acknowledge having
received and stored the Transaction log Buffer sent. Since the transport layer for these
packages is regular TCP/IP (no other protocols are supported), delays on waiting for the
mirror acknowledge are calculated by the transmission time of the packages plus the
time it takes to persist the transaction log records on the mirror side. No doubt distance
and network bandwidth are decisive factors for this more variable part of the delay.
Extreme distance or too small network bandwidth drastically limits scalability of a SAP
system. Result of extreme high database response times for SAP ABAP upgrade
processing usually develops into severe blocking lock scenarios around tables storing
number ranges or other critical resources. Therefore the distance to bridge with
Database Mirroring should be moderate, for a SAP OLTP kind of workload less than 100
miles with experience collected so far. The average throughput of such a network link
between principal and mirror should be able to sustain 5-10MB/sec for medium to large
systems and 10-20MB/sec for high-end systems.
42
Filename: 544804500.doc 43
rebooted or is shutdown minutes later, the witness now will detect, that the mirrored
database on the principal is not available anymore. However given the fact that
database mirroring went into suspended state minutes before, no automatic failover is
issued. One would have to perform the failover manually with the possible risk that
committed transactions got executed on the principle after database mirroring stopped
due to failure conditions. With this mode the distance between the two database
servers should be limited. From a pure workload perspective distances of less than 100
miles should be feasible given an excellent network bandwidth. However keep in mind,
in case of a failover there could be a severe performance impact by all the
communication between the SAP application tier and the mirror server going over the
very same distances as well. The usage of synchronous database mirroring with
automatic failover is ideal in scenarios where MSCS for SQL Server has been used in the
past. Dependent on the traffic between the application server instances and the
database server throughput conditions might even be more demanding than for a pure
synchronous solution w/o automatic failover.
The second step is to synchronize the principle and the mirror side. The usual way of
doing so is to take any kind of online backup of the principal side and restore that
backup on the mirror side with the option not to open the database for user
transactions. Afterwards apply all transaction log backups meanwhile taken on the
principal. At the point in time where all the transaction log backups got restored, stop
backing up transaction logs on the principal side and establish mirroring between
principal and mirror like described in Books online or the whitepaper mentioned earlier.
Filename: 544804500.doc 44
The third step would be to prepare the SAP ABAP and JAVA stack in the best way so
that either an automatic or manual failover can be achieved with none or minimal
downtime. Please note that this step is required specifically for the SAP application
design and as such might not be necessary for other applications. For the particular
situation of an automatic or manual failover this means that one needs to supply the
name of the mirror server in SAP profiles and environment, so that in the absence of
the principals, restarting SAP processes or new starting SAP instances do have the
information of the existence of a mirror server and can connect to the mirror server if
the principal does not respond. In detail the following changes need to be made:
1. User Environment of the User <SID>adm. Change the environment parameter
MSSQL_SERVER. The parameter usually has the value of the database server
assigned. It needs to be changed adding the mirror server name and the failover
database in this way:
MSSQL_SERVER=<principal>;FailoverPartner= <mirror>;Database=<DBname>
2. Changes in Default.pfl. The parameter dbs/mss/server (for releases before 6.20:
dbs/oledb/server) which usually contains the database server name as well needs to
be changed to contain the information on the mirror as well. This change would look
like:
dbs/mss/server=<principal>;FailoverPartner= <mirror>;Database=<DBname>
3. In order to keep the transport and correction system working despite the fact that
the current database server is the mirror after a failover, the DBHOST parameter in
the TMS domain profile needs to be changed as well. Usually DBHOST just has the
database server name assigned. Like in the other two cases the alternate mirror
name and database name need to be assigned. The information for that parameter
would look like:
DBHOST=<principal>;FailoverPartner= <mirror>;Database=<DBname>
44
Filename: 544804500.doc 45
counter to monitor for the principal will be ‘Log Bytes Sent/sec’. The shorter the
transactions are the bigger the difference between ‘Bytes Sent/sec’ and ‘Log Bytes
Sent/sec’ will be due to the overhead every submitted package will experience. See
screenshot below for those three counters.
On the other side it is interesting to monitor the receiving side, means the mirror
server. The less critical queue which can exist under all configurations of database
mirroring is the queue which can build up in the transaction log of the mirror server.
This queue refers to data, which has been transmitted to the mirror server, but has not
yet been applied to the mirror database. This kind of queue is less critical since the data
already is transferred to the mirror side. Hence no changes will get lost in case of the
principal server failing. Such a queue only can delay the recovery time a bit and hence
the failover time (either automatic or manual). The performance counter used to
monitor this queue is ‘Redo Queue KB’. It is normal that this value is not always 0, but
a few KB.
For synchronous mirroring configurations two very important counters to monitor are
giving information on the delay transactions are experiencing by the synchronous
mirroring configuration. The two counters are ‘Transaction Delay’ out of the
performance object ‘SQLServer:Database Mirroring’ and ‘Transactions/sec’ which can be
found in performance counter object SQLServer:Databases. The first counter will show
the accumulated delay time of all transactions waiting on acknowledgements from the
mirror side at that point in time. To set this number in perspective it needs to be
divided by the number transactions/sec delivers. The result will be the average delay
Filename: 544804500.doc 46
46
Filename: 544804500.doc 47
Database Snapshots
A SQL Server 2005 database snapshot instantly creates a completely new set of data
files that are used to store the original state of the pages at a point in time. No
additional log file is created. A database snapshot does affect performance on the
originating database due to a higher I/O load and a little more commutation time.
A database snapshot is extremely space efficient because it does not require a complete
copy of the data. A database snapshot shares unchanged pages with the original
database and only requires extra storage for the changed pages. After the snapshot is
created and a page is changed for the first time, SQL Server 2005 copies the original
page to the snapshot files (copy-on-write).
The SQL Server snapshot appears to the outside as a read-only version of the original
database which was frozen at a point in time. Therefore it can be used to recover from
48
Filename: 544804500.doc 49
eventual operator or user error by instantly being able to query a snapshot in a read-
only manner.
There are two basic scenarios for creating a snapshot:
Snapshot of the mirrored database. Create one or multiple snapshots on the
mirrored database in a database mirroring configuration to catch a human error like
deleting or manipulating data. In this case, the snapshot of the mirrored database
can be used for retrieving the original data. It is possible to have kind of a rolling
window of multiple snapshots. However be aware of performance implications in
form of CPU and I/O. Since SAP applications already perform updates at the point a
user logs into the system, this kind of database snapshot is not suitable for creating
a second frozen image of a database to run SAP applications against.
Snapshot on the primary database. Create a database snapshot on the primary
database when critical changes or imports are run and a failure or errors might
entail complete restoration of the database. For example, applying SAP support
packages or transports are not reversible, except by restoring the database to its
earlier state, which entails a huge effort. In this case, a database snapshot can be
used as a backup to revert the state of the database to the time when the snapshot
was taken.
Multiple SQL Server 2005 database snapshots of a database can be created. However,
as more snapshots are created, the CPU and I/O load increases. Note there are severe
differences to database snapshots or database clones hardware vendor can provide with
their storage infrastructure. In opposite to database snapshots on the hardware side,
SQL Server database snapshots cannot be:
Used as source for SQL Server Online Backups.
A clone of a SQL Server database snapshot cannot be created because a
database snapshot does not permit background copying.
The SQL Server database snapshot cannot be changed or attached to another
server as a duplicate database in order to use it as a basis for a sandbox or test
system.
Be aware that SQL Server Database Snapshot technology is used by SQL Server 2005
consistency check commands like DBCC CHECKDB or DBCC CHECKTABLE. In both cases
a snapshot of the complete database is created and the checkdb command runs against
the snapshot. This can have performance implications especially for customers scripting
their consistency checks of the database as DBCC CHECKTABLE commands for a subset
or for all the tables within the database. Creating a snapshot, performing a check on a
table and destroying the snapshot in loop over many tables will take substantially more
time than such a script used to take in SQL Server 2000. It might be worth to check
whether a complete DBCC CHECKDB might not even be faster than checking a portion
of the tables only with DBCC CHECKTABLE.
Besides features designed to improve protection and availability of data, SQL Server
2005 did introduce some features which enhance the availability of data during
administrative or operational tasks. Besides having online tools like dbcc indexdefrag()
(in SQL Server 2005: Alter index … REORGANIZE) already delivered in SQL Server
2000, efforts were made to decrease administrative scenarios requiring offline
operations. One of the reasons for more or less long downtimes in the past was the
Filename: 544804500.doc 50
creation or rebuild of table indexes. An improvement which should help for such cases
got introduced in SQL Server 2005
Where could this feature be used with SAP applications? A first very good area to
leverage this feature can be while applying SAP Support Packages. Since there is no
way currently rolling back SAP Support Packages, a Database Snapshot could be issued
before the first Support Package is applied. If something goes wrong while applying
Support Packages and the system needs to be rolled back to the starting point, this can
be done in an easy manner with a Database Snapshot. The same is true for applying
huge amounts of critical SAP transports.
Online Indexing
Online Indexing is a new feature of SQL Server 2005 that allows index maintenance
modifications to be performed online in systems such as SAP systems of any kind.
In SQL Server 2005, index creation can be performed in online or offline mode. In
online mode, parallel change activity on the table is allowed. Index maintenance is
performed offline by default with the table locked exclusively for this purpose.
With online indexing, SQL Server 2005 introduces a new parameter to the index DDL
commands. For example, simple command syntax includes:
Create index [x~0] on x (a) with (online = on)
Drop index x.[x~0] with (online = on)
In addition, during index creation, the number of CPUs used can be defined, overriding
the global setting for parallelism:
Create index x~0 on x (a) with (online = on, maxdop=2)
where maxdop=2 indicates that two CPUs are used.
Modifications to the table are allowed when an index is built, recreated, or dropped,
online. During this process, a transaction will not be blocked if it hits the primary table.
Modifications to the table or index create, rebuild, or drop are not blocked. Index
maintenance continues while the application runs.
Online indexing can be used to create, rebuild, drop, or reorganize an index including
BLOBs/CLOBs and to use index-based constraints such as the primary key. SQL Server
2005 tracks the transactions that were created during the index operation. Because this
process can be performed during production, maintenance that would otherwise have
required downtime or caused blocking on the system can be performed.
Creating an online index can take up longer using an online clause. Because there is no
blocking, the SAP applications are unaffected during the index creation. Online Index
creation also does use new methods of versioning which got introduced in SQL Server
2005. Therefore one can eventually increased tempdb usage during creating an index
online.
As of June 2006 online indexing is not directly supported by the SAP Application
Servers. Releases after Netweaver 2004S will support SQL Server Online Index for all
index creations, but indexes created during SAP release upgrades. In the SAP Database
Monitoring transactions one will find a screen which allows enabling online index
creation support globally for the SAP system. With the current releases the following
workaround can be executed:
50
Filename: 544804500.doc 51
Create the index required in the development system via SAP table maintenance
transaction
Check the name and the order of the columns of that index on the database
Create an index with the same name and the exact same column order with the
‘online’ option on the productive system with SQL Server methods using SQL
Management Studio.
Transport the correction of the index creation through test or quality assurance
systems to the productive SAP system.
Executing the transport on production, it will be checked whether the exact
same index does exist in the database already. If yes, only the missing Data
Dictionary entries in the SAP Data Dictionary will be made.
With this method, SQL Server 2005 online index creation is usable and was used in
productive customer’s systems dozens of times already.
There are small restrictions impacting the usage of online index create which would
apply to SAP database schemes:
LOB columns being part of INCLUDE column clause
Clustered index operations with LOB columns being part of a base table. This
does not impact the reorganization of BLOB/CLOB columns
One thing to note is that SQL Server 2005 Database Mirroring as described here is not
supporting any other recovery model than FULL. For creating or re-creating indexes this
can have very severe conferences of having all the changes documented in SQL Server
errorlog. Especially rebuilding a clustered index, this requires quite a large volume in
the transaction log of SQL Server. The table below can give a rough idea about the ratio
between the data in the database and the transaction log volume created by the
different activities:
Test Number Test Name Log-to-Data Ratio
1 Create nonclustered online index 1.15
2 Rebuild CI 1.34
3 Rebuild nonclustered Index (clustered 1.14
index exists)
eventually (if tempdb does not share partitions with the SAP database). Another
advantage observed is that indexes created with SORT_IN_TEMPDBDB usually tend to
have more contiguous space usage and hence might end up performing better scanning
such indexes. When rebuilding a clustered index the option SORT_IN_TEMPDBDB is not
needed since the data already is sorted and does not get resorted while the index
rebuilds
52
Filename: 544804500.doc 53
Having these two names separated allows very easily to transfer the virtual name to
any other given hardware might it be in the same data center or in a remote data
center without huge renaming issues within SAP profiles or other settings within SAP
applications.
Introducing Virtual names can be done with the following steps:
IP Addresses need to be assigned static
The Virtual Name does get an own TCP/IP Address assigned
Enter the Virtual Server Name with the assigned TCP/IP Address into DNS
Add the following Registry Entries to the Windows Server 2003 Registry:
o HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserv
er\parameters
o Add Multi_String_Value OptionalNames. Put Virtual Server Name in
Value Field
o HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0
o Add Multi_String_Value BackConnectionHostNames Put Virtual Server
Name in Value Field
Add new IP address to NIC:
Control Panel -> Network Connections -> properties of correct network card ->
click on Internet Protocol (TCP/IP) -> Properties -> Advanced -> Add new IP
address in the IP addresses section of tab IP Settings. Use the same subnet
mask as the original entry.
Reboot server
Change user environment of user which does start SAP Service (usually
SAPService<SID>), add:
SAPLOCALHOST = <alias name, e.g. saptst20>
SAPLOCALHOSTFULL = <alias name, e.g. saptst20>
Add SAPLOCALHOST and SAPLOCALHOSTFULL to Instance and Start profile –
Needed to show the virtual server name in SM51,etc
With these few steps one can assign a virtual name to a server very swiftly on demand.
Assuming a scenario where the production and test system are in two different
datacenters, the assignment of virtual names makes it extremely easy just to move the
virtual names of the production server to the test servers in the failover data center.
The usage of virtual server names for SAP instances really comes to great power in
combination with the usage of SAP logon groups, batch groups, RFC groups and Update
groups. Imagine a scenario where one of the application servers should be taken out for
hardware maintenance. It is possible to block the application server instance for new
user logins. As soon as the instance does not have any active users logged in anymore
and no running batch jobs anymore, it can be shut down. Now the virtual server name
immediately can be assigned to another server (which does have the SAP ABAP or Java
stack pre-installed for the particular system) and immediately can be brought back in
production. No changes on logon groups, batch groups or RFC groups are necessary.
Independent of the usage of virtual server names, in order to achieve a good flexibility
in order to swap server or instances, it is highly recommended not to assign Users
directly to specific servers, but use SAP Logon Groups and other abstraction
functionalities SAP does offer.
Filename: 544804500.doc 54
sys.dm_exec_query_stats
The sys.dm_exec_query_stats DMV stores aggregated performance data for queries
that were run since SQL Server was started. This data can be used to provide a trend
analysis of how the system is performing.
54
Filename: 544804500.doc 55
The data provided in this view is similar to the data from SAP Database Monitor. This
view also contains additional data that is not available in earlier versions of SQL Server
and SAP including:
A Select statement against this view displays performance statistics on statements
in the statement cache and some statements already flushed out of the cache.
However, data on queries executed a number of hours earlier on a busy system can
be flushed.
A trace event is created in order to flush the statistics. The event and performance
data can use the SQL Server trace framework or the SQL Server Profiler.
For sys.dm_exec_query_stats, a query is identified using sql_handle. This handle
obtains the text of the query. The execution plan of the query is obtained using
plan_handle. The result is an XML type query plan.
Examples of queries leveraging this view include:
select * from sys.dm_exec_query_stats
This query lists the performance figures of all queries in statement cache.
select * from sys.dm_exec_sql_text(sql_handle)
This example shows the SQL statement text where the specific handle was read
from the result set of the first query.
select query_plan from sys.dm_exec_query_plan(plan_handle)
This query shows the query plan.
The results from this DMV contain columns with performance metrics for each query
including:
Physical reads and writes.
Logical reads and writes.
Time spent in common language runtime (CLR) for all statements referring to a CLR
function.
Number of executions.
Worker time showing the time spent in processing.
Elapsed end-to-end time from the point when the request came into SQL Server to
the time when the result is returned including statement execution and wait times.
Average per executions calculated from the columns displayed.
See different examples of queries which can be used to retrieve different types of
information from sys.dm_exec_query_stats.
• Example 1 - Show Queries executed more than 1000 times with longest
execution times per execution:
select top 50 total_elapsed_time/execution_count, * from
sys.dm_exec_query_stats where execution_count > 1000 order by
total_elapsed_time/execution_count desc
• Example 2 - Show Queries executed more than 1000 times with highest logical
reads per execution
SELECT TOP 50 (qs.total_logical_reads + qs.total_logical_writes)
/qs.execution_count as [Avg IO], qs.execution_count,
Filename: 544804500.doc 56
56
Filename: 544804500.doc 57
sys.dm_db_index_usage_stats
In a SAP landscape over a period of time, the custom indexes on tables for particular
programs can change. For example, due to business or program changes, some indexes
might no longer have relevance. In addition, a non-clustered index created previously
by a customer can consume extra space.
The sys.dm_db_index_usage_stats view monitors index utilization. This view shows
where index utilization is occurring on the aggregate and identifies queries and indexes
that are not being used.
The sys.dm_db_index_usage_stats view:
Determines whether indexes are actually being used.
Lists the index, categorized by user and system, and indicates how the indexes have
been used. It lists the category of usage of indexes as user queries (read or modify
data) and system usage (update statistics, consistency checks).
sys.dm_db_index_usage_stats counts the data during the up-time of the database
server. When SQL Server is shut down, the data is lost. The data is used to analyze
whether custom deployed indexes are still in use. The data is tracked on a long-term
Filename: 544804500.doc 58
basis to ensure that special periods are covered such as month-end or quarter-end
reporting.
Do not use the data to delete SAP standard indexes. In some cases changes in the
usage of SAP functionality or changes in customization or in leveraging new SAP
functionality might require SAP indexes to be deployed during the installation of the
SAP product. For this reason, do not delete SAP deployed indexes even when those
shown are not used.
The following table shows the data of the user category including the categorization of
seeks, scans, and lookups in SQL Server 2005.
TBTCO__0 9729 12 1046 3740 5/23/05 5/23/05 4:00 5/23/05 5/23/05 13:48
4 3 2 13:48 13:45
A seek accesses a table that uses the index B-Tree; the scan does not indicate the
number of rows being retrieved. A seek can read the whole table using the index
B-Tree.
A scan reads the data layer without the index B-Tree, for example, to scan the
table’s data layer to create an index.
A lookup can only occur on a clustered index when additional non-clustered indexes
are defined on the table. The term lookup categorizes a seek on a non-clustered
index. In this case, a clustered index is used to retrieve the data rows when the
non-clustered index does not cover the query. The sum of all seeks on non-
clustered indexes is greater or equal to the lookups on the clustered index.
Updates show how often an index has been updated for data modifications. An
update modification does not always trigger an index update. With SQL Server
2005, only indexes affected directly by the updated date are changed.
An example of a query which finds non-used indexes in the current database includes:
select object_name(object_id), i.name
from sys.indexes i
58
Filename: 544804500.doc 59
sys.dm_db_missing_index_details
Three more DMVs got introduced to point out Missing indices. For each given query SQL
Server 2005 Query Optimizer knows what the most optimal indexes would be. In case
such indexes do not exist and an alternative index needs to be chosen, SQL Server
2005 would note such cases when the optimal index would provide a substantial better
performance. So far this new feature is restricted to suggest non-clustered indexes on
normal tables only. It does not take indexed view into calculation. It also has a limit of
suggesting 500 indexes only. After a list of 500 indexes is noted, it does not add new
suggestions to the list. The list will be emptied with restarting the SQL Server instance.
As with the former DMV, there is no persistency layer for this DMV. Especially for SAP
applications with a limitation of defining indices with 16 columns only, the index
recommendation often figure out to contain more than 16 columns and hence might be
hard to adapt. Even with indexes which could be created with the SAP Table
Maintenance transaction one should be careful creating each an every index possible.
Keep in mind every index creates additional resource consumption in space and
maintenance of the table and indices during modifying operations. Before creating such
a suggested index, one should investigate which SAP ABAP or JAVA logic did cause the
statements in need of such indices and eventually discuss Application coding changes to
avoid creating dozens of new indices.
There are three different DMVs which store the data around indices missing:
1. sys.dm_db_missing_index_groups: Represents so called index groups. An index
group represents one or more missing indexes. In this table the index group id is
mapped into the specific index IDs. As a result one will find one entry for a
query just missing one index, two entries for a query missing two indices, etc
2. sys.dm_db_missing_index_group_stats: Stores costing and eventual usage data
for specific an index group.
3. sys.dm_db_missing_index_details: Contains the suggestions of the index
structure which is missing
To detect the 50 indices which would have most impact of all the indices recorded
as missing one would run this query
SELECT TOP 50 convert(int,(user_seeks + user_scans) *
avg_total_user_cost * (avg_user_impact * 0.01)) as index_advantage,
migs.group_handle, migs.user_seeks, migs.user_scans,
object_name(mid.object_id) as tablename, mid.equality_columns,
mid.inequality_columns, mid.included_columns
FROM sys.dm_db_missing_index_group_stats migs,
sys.dm_db_missing_index_details mid, sys.dm_db_missing_index_groups
Filename: 544804500.doc 60
mig
where migs.group_handle = mig.index_group_handle and
mid.index_handle=mig.index_handle
ORDER BY index_advantage desc
[MANDT],
[LOEKZ], [EBELN],
[MATNR], [EBELP],
3981807 915 1019368 0 EKPO ELIKZ] NULL [WERKS]
[MANDT],
[BSTNK],
131916 12 2141 0 VBAK [KUNNR] [AUDAT] NULL
[MANDT],
[ARCHIVED],
33762 146 237 0 SMSGL [APPID] [ERRLEVELN] [LOGNUM]
[MANDT],
[SETCLASS],
[SETNAME],
31212 8 15372 0 SETLEA [VALSIGN] [LINEID] NULL
[RCLNT], [RUNIT],
[RRCTY], [RITEM],
[RVERS], [RLDNR], [TSL09],
19030 1461 102 0 ECMCT [RYEAR] [PLEVL] [HSL09]
The last 3 columns contain the column names of the columns which should be included
in the recommended indices. When you create such an index, order the columns in the
index by adding the columns listed in ‘equality_columns’ first, then add
‘inequality_columns’ and at last the columns listed under ‘included-columns’. This at
least is a sound rule to build so called covering indices (indices which cover the select
list as well as the where clause of the query). If you only want to optimize for the
where clause, then define the new index with all the ‘equality_columns’ and then add
the most selective of the columns suggested under ‘inequality_columns’.
60
Filename: 544804500.doc 61
features for performance tuning. These features leverage SQL Server specific
functionality, as well as some functionality that is SAP specific.
62
Filename: 544804500.doc 63
Performance
(Several Days)
On the left, the ST03 sample
provides a summary of
performance over the last 30
days such as the times spent in
the different components. ST03
provides an overview of the work
generated by the SAP application
layer and shows all process
types. Note that the sample
shows a history of the number of
dialog steps.
CPU is Pegged
When the CPU is pegged, check the SQL Server configuration max degree of parallelism
parameter. See the preceding “SQL Server Installation with SAP” section. If this setting
is other than 1, set it to 1. Having the parameter set to other than 1 could permit a few
queries to use most of the CPU on the server, thereby increasing the I/O volume by a
factor of 2 to 4.
If the max degree of parallelism parameter is set to 1, check the threads that can be
run in SQL Server 2005 by executing the SQL statements described below. In system
processes such as the SQL Server 2005 DMV, the start time of a statement and the
handle to the statement are displayed.
Execute in SQL Query Window:
select * from sys.dm_exec_requests
Check statements running longest on threads.
Use sql_handle to get the SQL statement.
Execute in SQL Query Window:
select * from sys.dm_exec_sql_text(<sql_handle>)
Check the statements for their selectivity. Determine if there are statements that do
not contain specific Where clause restrictions and return large amounts of data.
64
Filename: 544804500.doc 65
storage for Windows OS. Please note that the way to setup can differ from the way
such devices need to be configured for UNIX
There are too few Host Based Adapters (HBA). Host Based Adapters do have
limitations in throughput. A 2GigBit Adapter is good for providing a throughput of
160-180MB/sec with a good performance. Beyond this, the Adapter starts to
become a bottleneck.
The queue depth of such an HBA is left as the default of 32, instead of setting it to
128 or even 255. Check with the storage hardware vendor for the proper settings
and maximum values.
SecurePath or PowerPath software was incorrectly configured in failover mode,
instead of workload balancing mode. These two software programs provided by two
different SAN vendors can be setup in a way to provide failover between two HBAs
or can be configured to provide load balancing. The latter configuration is preferred.
Backup activity was not included when calculating the I/O bandwidth demands. SQL
Server online backup reading tremendous amounts of data can create an additional
I/O workload. On systems which are used around the clock it often is difficult to
define a time period with a low workload. Therefore the possibility of scheduling a
backup in a time of low activity might hardly exist. In order to backup 100GB in one
hour to a backup medium another 40MB/sec not to be read in parallel to the already
existing workload. Not having any I/O bandwidth left for SQL Server online backup,
certainly can cause performance issues and slow down backup activity.
SAP BW and mySAP SCM are applications where read performance is very important
and the most critical reads are performed in a 64 KB format. These particular SAP
products typically perform critical queries such as joins over various tables. In addition,
time critical processes, such as in SAP BW, require excellent write performance. In SAP
BW, performance on tempdb is also critical.
Windows Performance Monitor can determine the average I/O performance values. In
this case, measure I/O performance for at least 15 minutes, usually for one hour
minimum, in order to ensure that the values are representative of actual performance.
In high-end systems, I/O SQL Server data files perform in the following range:
Up to 10 ms is good.
10 to 20 ms is acceptable. Less than 20 ms is acceptable for an I/O against data
files.
20 to 30 ms is not acceptable.
Above 30 ms shows an effect on the performance of the system and it is usually not
acceptable, especially in high-end systems.
SQL Server transaction log file performance can be categorized in the following range:
Up to 10 ms is good.
10 to 20 ms is acceptable.
Over 20 ms indicates that CPU resources of the database server are not fully
utilized.
SQL Server 2005 has multiple 64 KB buffers to which the SQL threads write their
transaction log entries. If one thread executes a commit, the transaction log buffer
holding the commit record needs to be flushed. The thread writing the commit record
has to wait until the acknowledgement of a successful I/O write of the buffer is returned
by the I/O subsystem. If this takes a long time, the thread waits and it cannot be used.
There are limitations on how many outstanding I/Os to the transaction log are
acceptable. Independent on the number of I/Os, there also is a limit of how much
outstanding volume is acceptable. If one of those limits is exceeded, SQL Server will not
issue any more write I/Os towards the transaction log. In cases where I/O performance
against the SQL server transaction log is extremely low such situations of exceeding
these limits could occur. In such a case a drop in the workload of SQL server could be
observed or at least SQL server hardly will be able to leverage existing CPU resources.
66
Filename: 544804500.doc 67
This DMV can also be used to find out whether the proportional fill is working properly,
as described here.
The output also indicates whether all files show similar performance. The numbers get
accumulated over the entire run time of the SQL Server instance from startup. For this
reason, these numbers can be much lower than those indicated by current Windows
Performance Monitor measurements under a very high workload of a system. If a
system does have a very high workload during a few hours only, but the rest of the day
the performance is great the values this DMV can show are not reflecting the entire
truth. The accumulated output data might hide such timeframes with poor I/O time
accurately and the data cannot be reset. Therefore using Windows Performance Monitor
to find out more about the I/O performance distribution throughout the day makes a lot
of sense.
The SAP Fetch phase is used to count the time required to retrieve the data from the
database server to the application server. Most often the Fetch time is the smaller
amount of time, unless large
numbers of rows are returned.
In ST05, double click the open line
of a statement to display the full
statement and the parameters
submitted to the statement. At
the end of the statement text, the
Stored Procedure name or the
Dynamic SQL statement string
provides SQL Server port-specific
information about how the SQL
statement from ABAP was
executed in SQL Server 2005.
This comment indicates when
which of the two connections was
used for the statement and
whether a server side cursor
(extremely rarely) was used. For example, the description conn 0:1 indicates that the
uncommitted read connection (dirty read) of the SAP process was used to execute the
statement.
68
Filename: 544804500.doc 69
view the query execution plan. If the analysis is performed immediately after the trace is
taken, the query execution plan still existing in the cache is displayed. If the analysis is
performed at a later time after the trace is taken and the query execution plan is no longer
in cache, a new query execution plan is created. Unfortunately, there is no easy way to
determine if the execution plan is in cache or if it was newly generated.
Overview Page
On the left, the ST04 Overview
page provides general SQL Server
2005 information including the
operating system release on which
SQL Server runs. The most
important information includes the
cache hit ratio numbers of SQL
server Buffer pool and Statement
Cache and the trace flags used.
Details Page
On the left, the ST04 Details page
selections include:
Checks on the errorlogs and
provides a list of deadlocks.
Checks for immediate blocking
lock situations or statistics on
lock situations of over one
minute.
Filename: 544804500.doc 70
Query Statistics
Page
On the left, the ST04 Query
Statistics page shows the
performance data accumulated by
each application server or for
selected application servers.
70
Filename: 544804500.doc 71
Query Performance
Statistics Page
On the left, the next sample
shows the ST04 Query
Performance Statistics page. ST04
displays the performance numbers
for the top executed queries. The
list is sorted by the sum of
execution times including the
fetch time, maximum execution
time per query, number of
executions, average rows returned
per execution, and average
execution time. See the column
presenting the average execution
time marked in red. From this
page one can get to the query execution plan again, which has been displayed before
already. One also can jump to the ABAP source Code location.
SAP BW Queries
The best way to investigate performance issues with SAP BW is to repeat and trace the
queries. Similar to other OLAP warehouse products, SAP BW tries to buffer queries and
associated results. The base foundations allow a query to be run manually for
investigation. SAP BW queries are named and stored in the SAP BW cache.
Using the SAP BW transaction code RSRT, a SAP BW query can run repeatedly in order
perform investigations. The RSRT transaction helps to rule out issues on the client side,
such as the client reporting or network issues on the way to the client.
The RSRT transaction can be used with the option to Execute + Debug. To use this
option:
Browse for a query or type the name of the query.
Select the query display option such as List, BEX Broadcaster (SAP BW Business
Explorer Broadcaster), or HTML (HyperText Markup Language).
Click Execute + Debug to display a pop-up window that enables certain items to be
selected. In addition, a second window can appear requesting query parameters.
Filename: 544804500.doc 72
Range Partitioning
In SQL Server 2005, an un-partitioned table contains a data layer, with one or more
index B-Trees on top. In the data layer, the data is sorted according to the clustered
index key if there is a clustered index on the table.
With range partitioning, the physical structures for the data layer and the index B-Tree
are aligned with the partitioned data, making it easy to move a partition. Whether an
72
Filename: 544804500.doc 73
index contains the column with which the partition is aligned or not, B-Trees are aligned
with the partition column.
Notice the following example diagram.
When a partition is deleted from a partitioned table, the partition is switched into a non-
partitioned table of the same structure using a metadata operation that takes only one
or two seconds. No data is moved. The status of the table and its partitions will be like
shown in the following diagram.
NewTable BigTable
SQ L syntax to remove a
partition: Alter table
BigTable switch partition 1
to NewTable
Deleted partition
becomes a new separate
unpartitioned space
1994 1995 1996 1997 1998 1999
Once a partition is transformed into this new non-partitioned table, the table can be
dropped, truncated or archived. Dropping the table of millions of rows which
represented one partition of a partitioned SAP BW table will take minimal time. It just is
a matter of a few seconds. However the deleted rows cannot be restored from the
transaction logs.
SAP supports SQL Server 2005 range partitioning on the following classes of tables in
SAP BW versions 3.5 and higher:
Persistent Staging Area (PSA) table. This is the main table for the staging data
coming from the outside into SAP BW. Here the partition criteria is the ‘LoadID’. The
LoadID is an artificial partitioning key for PSA tables that correlates to the number
of rows per partition.
F-Fact (part of a SAP BW InfoCube). The F-Fact table in the cube allows
duplicate rows. The F-Fact table contains the ‘Request ID’. This is the request that is
associated with loading the data into the cube. The Request ID is the dimension to
which the partitions are lined. Each new load gets stored in its own partition.
E-Fact table (part of a SAP BW InfoCube). The partitioning of the E-Fact table is
not mandatory, but it is recommended because the data from F-Fact table is
compressed into the E-Fact table. Duplicates in the F-Fact table get rolled up into
one row, making the E-Fact table smaller. Since the Request ID is not part of the
E-Fact table, the implementation of SAP uses the time dimension for partitioning.
Either the month or the fiscal year can be used for E-Fact tables. The time range is
defined at the creation time of the cube.
Filename: 544804500.doc 74
Creating Aggregates
Materialized aggregates and pre-aggregated query results are important for SAP BW. In
cases where many well defined reports are running on a daily basis, typical practice is
to create SAP BW aggregates to pre-aggregate reports or parts of reports. When there
are hundreds of interactive users, it is vital to build SAP BW aggregates for well known
reports. Creating SAP BW aggregates avoids marginalizing database resources to
perform aggregation on the fly while executing reports.
When SAP BW aggregates are created against a SAP BW cube, performance is improved
by using the aggregates during the interactive query phase. However, during the delta
load phase, these aggregates need to get updated (rolled-up), which extends the run
time of the delta load phase. The alternative to this trade-off is to marginalize resources
in order to read huge volumes of data from the fact tables of the SAP BW cubes.
74
Filename: 544804500.doc 75
When the block size is set to one million, SAP BW uses 10 steps to create the
aggregate. In this case, SAP BW searches the query for a Where clause that
contains an additional "artificial" filter that scans only one million rows per step.
The challenge is to define the artificial filter. Because SAP BW calculates the block
size automatically, it might not be possible to enter some ranges manually,
depending on the data distribution.
Use the SAP BW SPRO transaction to set the block size for an aggregate. To run SPRO,
select SAP Reference IMG, then Business Information Warehouse, then General SAP BW
Settings, and then Parameters for Aggregates. In SAP BW 3.5, the default block size for
the fact table is 100 million rows.
Benefits of using a smaller block size. With a smaller block size, each of the
steps can be run serially using far fewer resources than creating an aggregate using
one large block size. The drawback is that a large fact table must be scanned
multiple times. Smart table partitioning eliminates partitions in the scan process.
Setting the block size. There is no optimal setting for the block size. The size is
dependent on the type of aggregate, the size of the fact table, and the available
physical resources such as the number of CPUs and amount of physical memory.
One solution is to create the aggregate using one large block size to see if there are
performance issues and/or increased tempdb usage. If this occurs, reduce the block
size and create the aggregate in multiple steps.
Aggregate Compression
Using compression for aggregates means removing the Request ID, as described in the
following section "Cube Compression". Compression reduces the size of aggregate
tables. This improves query performance and saves space.
Use the SAP BW RSA1 transaction to start compression. To run RSA1, select
InfoProvider on the left side and then right-click on the cube where the aggregates are
to be compressed. In the pop-up window, click Manage. In the next window, select
Rollup and then mark Compress after rollup in the Aggregates check box.
However, for the initial load of an infocube, it is best practice to drop the indexes before
the load. This improves the load time dramatically. Then recreate the indexes after the
load. After creating a new infocube and performing an initial load, refer to the “Missing
or Outdated Optimizer Statistics” section for more information.
Cube Compression
Cube compression in SAP BW can have a massive impact on database tables. On a
database level, every infocube uses the E-Fact table and F-Fact table. The E-Fact table
contains rows without a Request ID; the F-Fact table contains rows with a Request ID.
SAP BW stores a Request ID in the fact tables of the infocubes. Every load job that
inserts data into the cube is given a new Request ID.
The rows in the fact tables are identified by a number of key columns. Because of the
Request ID, a unique row can occur many times. This allows data from a certain load
job to be deleted if necessary. However, creating aggregates or running queries directly
on the cube increases space requirements and processing power.
Cube compression removes the Request ID and combines all rows with the same key
columns. Depending on load job history, the reduction in the number of rows can be
huge. The result is placed in the E-Fact table. The SAP BW RSA1 transaction can be
used to initiate cube compression.
Select the infocube after selecting InfoProvider on the left side. Right-click on the cube
to show a pop-up window and then select Manage. In the next window, select Collapse
to activate the compression.
76
Filename: 544804500.doc 77
64-bit computing. If the same complex query were run on SQL Server 2005 (64-
bit) on a server with 64 GB of memory, the query can be assigned up to 16 GB of
memory to perform joins, sorts, and grouping, leaving only a very small number of
queries needing tempdb. Most queries can be performed fully in memory using the
data buffers available to SQL Server 2005 (64-bit), greatly improving performance.
In addition, having the capability to address more than 64 GB of memory directly
provides opportunities that were previously unavailable due to the drawbacks of the 32-
bit platform. Doubling or quadrupling memory in a dramatic manner can reduce the I/O
rate. This improves the response time by a factor of 2 to 4 and lowers investment costs
for I/O hardware. In addition, SQL Server 2005 (64-bit) can be expanded in workload
areas that could not be touched with 32-bit platforms.
Due to the processing power of the most recent 64Bit processor becoming so powerful,
one should keep in mind that one configures a dedicated database server used in a SAP
landscape with enough memory to really be able to leverage the CPU resources. One
should configure around 4GB of memory for one processor core (disregard
Hyperthreading).
78
Filename: 544804500.doc 79
The physical memory and CPU limitations for the 32-bit and 64-bit Windows operating
systems are shown in the following table.
Physical Memory and CPU Limits9 32-bit 64-bit
Windows Server 2003 Standard Edition 4 GB/1 to 4 CPUs 32 GB/1 to 4 CPUs
Windows Server 2003 Enterprise Edition 64 GB/1 to 8 CPUs 1 TB/1 to 8 CPUs
Windows Server 2003 Datacenter Edition 64 GB/1 to 32 CPUs 1 TB/1 to 64 CPUs
All recent SAP products are available on IA64 and x64. This includes ABAP and Java
Stack. Due to higher memory resource consumption on the application server side by
SAP Unicode systems, one should consider SAP Unicode implementations on 64Bit
exclusively. Especially for all SAP applications demanding a lot of memory resources like
SCM Livecache or SAP ABAP stack for R/3, BW and other products are available on both
64Bit platforms.
SAP meanwhile announced in April 2006 that SAP product releases entering the market
from the year 2007 on, will be 64Bit releases only. Microsoft plans to support these SAP
product releases with 64Bit SQL Server 2005 and later 64Bit releases of SQL Server
only.
Transition to 64Bit with SAP is not a one or nothing move. The transition can be done
server by server or system by system. SAP does support platform heterogeneous
9
Product listings are for reference only. The listings do not represent final or actual product names or convey
equal functionality between the 32-bit and 64-bit versions of Windows.
80
Filename: 544804500.doc 81
systems between the three different platforms. Pretty common might in the past
already was to run a bigger IA64 database server in a high-end system, but leaving the
SAP application server tier on x86 commodity application server. This still can be done
using x64 servers for the SAP application tier. Even having the SAP Central Instance
running in a cluster with the IA64 database server and having the rest of application
server instances on x86 or x64 does work since SAP stores the SAP executables on the
Central Instance in platform dependent directories.
Configuring a 64Bit server for running a SAP ABAP instance, one should calculate 4GB
real memory per processor core to really be able to fully leverage the processor
resources available. The same is true for SAP JAVA instances.
Solution Architecture
This section describes typical reference architectures that are capable of supporting
small scale, mid-sized, and the largest, most demanding SAP implementations. The
architectures show the basic elements that can be used in a variety of implementation
scenarios. This section also provides an example of Microsoft Information Technology’s
(IT) running SAP with SQL Server 2005 implementation.
In practice, each SAP implementation will need to be adapted and designed jointly with
a SAP-certified hardware vendor in order to address the customer’s unique
requirements, for example, pre-existing infrastructures, business models, or business
impact assessments.
Each of the mySAP with SQL Server 2005 reference architectures meets the following
requirements:
High availability. The architectures are designed for high availability to provide the
best performance and to ensure fault tolerance.
Scalability. Additional servers can be added quickly and easily without disrupting
the existing site, enabling SAP installations to rapidly increase the number of
concurrent users.
Support for large volumes of data. The application and database configuration
can grow from hundreds of gigabytes to multi-terabyte databases.
Hardware
The SAP with SQL Server 2005 reference architectures are designed to use commodity
servers as well as high end server architectures and storage that is available from
leading hardware vendors. Especially leveraging commodity type architectures reduces
the TCO and ensures that maintenance and support costs can be well-managed.
Filename: 544804500.doc 82
Architectural Considerations
The mySAP with SQL Server 2005 architectures are designed to provide maximum
availability and improved reliability by offering multiple levels of failover support and
redundancy including:
Failover clustering. SQL Server 2005 can run two to eight server nodes in a
failover cluster to provide redundancy in the event of server downtime.
Database Mirroring. As an alternative to Failover Clustering, Database Mirroring is
introduced.
RAID. Common Redundant Array of Independent Disks (RAID) is used to provide
redundancy in the event of a disk failure.
Storage. Storage Access Network (SAN) and Network Attached Storage (NAS)
technologies can be designed with complete redundancy to ensure data integrity
and avoid data loss. SQL Server 2005 is optimized for native integration with SAN
hardware.
High-Availability measures
SAP products in combination with SQL Server 2005 can leverage failover clustering as
one of the High Availability methods. A typical Microsoft clustering scenario includes
running the SAP Central Instance (CI) on one of the cluster nodes and SQL Server 2005
on the other cluster node. In this case, if the primary node for SQL Server 2005 or for
the SAP CI fails, or if that node is taken offline for maintenance, the clustered
components will start on the active cluster node with no service interruption.
Another possibility to achieve high-availability could be to still use MSCS to cluster the
SAP Central Instance in an active-passive cluster or use SAP’s Replicated Enqueue
Technology and have SQL Server 2005 using Database Mirroring which got introduced
in this document already. The possibility of traditional log-shipping also would be
possible. For more details on High-Availability and other measures see here
RAID
SAP applications with SQL Server 2005 should leverage common RAID levels including
1, 5, 1+0, and 0+1, as shown in the following diagrams. For the best performance with
full recoverability, customers frequently use RAID 0+1. RAID 5 can be used as a lower
cost alternative. The choice of RAID level is dependent on the workload and this choice
can directly affect the way SQL Server 2005 performs.
Note that RAID levels greater than 10 (1 + 0) offer additional fault tolerance or
performance improvements. However, systems using RAID 10 and greater tend to be
proprietary. For more information about specific RAID system capabilities, contact the
hardware vendor.
For more information on general RAID levels check on this link:
http://en.wikipedia.org/wiki/RAID1#Standard_RAID_levels
or on this whitepaper which also explains some other storage features of SQL Server
eventually applicable for SAP. However please note that not all the described measures
in the whitepaper pointed to are applicable for databases related to SAP applications:
82
Filename: 544804500.doc 83
http://www.microsoft.com/technet/prodtechnol/sql/2005/physdbstor.mspx
Users
Architecture Description
Server
Local Storage
Architecture Description
10
tempdb is typically 1.5 times the size of largest SAP fact table.
84
Filename: 544804500.doc 85
Architecture Description
Servers
SQL Server 2005 Database 2 commodity servers with each having 2 to 4 processors,
Server / SAP Central Instance with 4 GB RAM per CPU core. Up to 24GB GB RAM is
(CI) Server assigned to support SQL Server 2005.
Filename: 544804500.doc 86
Architecture Description
Networked Storage
86
Filename: 544804500.doc 87
Architecture Description
Servers
SQL Server 2005 Database 2 commodity servers with each having 2 to 4 processors,
Server with 4GB per CPU core
SAP Central Instance (CI) Server MSCS solution on 2 small 2 processor servers with 4GB
each using traditional SAP CI clustering or Replicated
Standalone Enqueue
Networked Storage
Users
MSCS Cluster
2 Servers:
SQL Server2005 SAP Central (4- 64 processors,
Database(node A) Instance up to 512 GB RAM)
(16-480 GB RAM) (node B)
heartbeat
Storage
(SAN)
Architecture Description
Servers
88
Filename: 544804500.doc 89
Architecture Description
Networked Storage
Servers
Networked Storage
90
Filename: 544804500.doc 91
Users
SAP NetWeaver
Application Server
Instances
1 to n Servers:
(2 to 4 processors,
2 GB RAM per core)
MSCS Cluster
SAP Central 2 Servers:
(SAP CI is on Instance(CI) (Dual-core processor
the server with Passive
SQL Server2005 Failover Node 64 processors,
SQL Server2005
to speed up Database
(2 GB RAM
) 512 GB RAM,
the Delta load
) 32 GB disk drive on each)
heartbeat
Storage
(SAN)
Architecture Description
Servers
Architecture Description
Networked Storage
92
Filename: 544804500.doc 93
Users
6 SAP NetWeaver
Application Server
Instances
6 x64 Servers
HP DL585 (4 processors,
32 GB RAM each)
SQL Server
2005Database
Mirroring 2 Servers:
SQL Server2005 x64 HP DL585
SQL Server2005 Mirror (4 processors, dual core,
Principal 48 GB RAM each)
Change
Records
Architecture Description
Servers
Architecture Description
SQL Server 2005 Database 2 servers with each having x64 HP DL585 4 processors
Server (dual-core) with each having 48 GB RAM.
Networked Storage
94
Filename: 544804500.doc 95
features, which proved to work great for specific customer situations. Another
advantage of SAN/NAS devices usually is the huge cache of multiple GBs these devices
are equipped with. This at the end means that not every I/O operation coming from
SQL server really hits the underlying disks, but can be served out of those caches.
Experience is that the cache hit ratio of these caches is nowhere close cache hit ratios
of SQL Server, but that one certainly can get more I/O throughput per disk compared
to direct attached storage with small caches on the controllers.
configured on the storage backend, the volume being locked down for changes
while the replication of the 3 blocks was executed might be of a size of 940KB.
Means all subsequent reads which would affect this 940KB locked down are
blocked. Since transaction log writes usually write sequentially into the
transaction log files, such kind of lockdown of bigger storage blocks on the SAN
backend can impact performance in a major way. A workaround can be an
alternative stripping which will reduce the volume of the storage block locked
down or host based stripping. However latter could come with the price needing
an additional volume manager software in order to use MSCS.
The latency time introduced by synchronous storage replication is not the same
than a ping between the two storage devices. Even over 100 Miles, a ping
between the two devices might take 3-4ms. However this does not necessarily
reflect the time it takes to replicate a block in storage. The time for replication
could be way higher due to the fact that there are additional software
components which are involved.
No doubt, the longer the distance the higher the latency.
In order to get a feel for the impact of synchronous storage replication it is best
to perform some tests with the devices close together. This will get a good
indication for the ‘fixed’ costs of the synchronous storage replication. This will
allow as well tuning this kind of replication from the storage side. As a second
step after the performance is sufficient using synchronous storage replication
with devices close by, it does make sense to perform the same tests on the
desired distance.
96
Filename: 544804500.doc 97
SAP AG:
http://www.sap.com/index.epx
SAP NetWeaver:
http://www.sap.com/solutions/netweaver/index.epx
Note that the SAP OSS Notes and SAP Product Support Matrix are only available to
registered customers of SAP AG.
Did this paper help you? Please give us your feedback. On a scale of 1 (poor) to 5
(excellent), how would you rate this paper?
98