SAP DB2 Storage Layout
SAP DB2 Storage Layout
DB2 Database Layout and Configuration for SAP NetWeaver based Systems
Helmut Tessarek DB2 Performance, IBM Toronto Lab
Trademarks
The following terms are registered trademarks of International Business Machines Corporation in the United States and/or other countries: IBM, AIX, DB2, DB2 Universal Database, Informix, IDS SAP, mySAP, SAP NetWeaver, SAP Business Information Warehouse, SAP BW, SAP BI and other SAP products and services mentioned herein are trademarks or registered trademarks of SAP AG in Germany and in several other countries. Microsoft, Windows and Windows NT are trademarks of Microsoft Corporation in the United States, other countries, or both. UNIX is a registered trademark of The Open Group in the United States and other countries Oracle is a registered trademark of Oracle Corporation in the United States and other countries LINUX is a registered trademark of Linus Torvalds. Other company, product or service names may be trademarks or service marks of others.
Agenda
Part 1: DB2 Database Layout for SAP NetWeaver based Systems Part 2: DB2 Database Layout for SAP Business Warehouse
Part 1
DB2 Database Layout for SAP NetWeaver
Overview: SAP NetWeaver usage types SAP installation options for DB2 File system- and table space container layout Table space attributes Recommendations to improve I/O performance
The usage type affects the DB2 database layout: Depending on the usage type the ABAP and/or Java runtime environment is installed. Each environment requires different DB2 table spaces. SAP Business Warehouse may be installed on multiple DB2 database partitions. This may require to adapt the initial database layout manually during the installation.
5 IBM SAP DB2 Center of Excellence 2008 IBM Corporation
Tablespaces (D/I) SYSCATSPACE SAPSID#TEMP SAPSID#USER1 SAPSID#EL<Rel.> SAPSID#ES<Rel.> SAPSID#LOAD SAPSID#SOURCE SAPSID#DDIC SAPSID#PROT SAPSID#CLU SAPSID#POOL SAPSID#STAB SAPSID#BTAB SAPSID#ODS SAPSID#DIM SAPSID#FACT SAPSID#DB
Usage DB2 data dictionary Sort, temp tables, reorg Default TS Dev. Environment Loads Dev. Environment Sources Screen and Report Loads Screen and Report Sources ABAP Dictionray Log-like tables (e.g. Spool) Cluster tables Pool tables (e.g. ATAB) Master data Transaction data ODS, PSA tables Dimension tables InfoCube and Aggregate fact tables Tablespaces for Java Stack
2.
3.
AutoStorage Option Should NOT be marked, if you want to use SMS or DMS Raw Devices. SAPinst generates a DDL-File that you can edit and execute manually to create tablespaces.
In a Storage Area Network (SAN) storage appears to hosts as local SCSI disks (LUNs). A LUN can be mapped to anything within a SAN storage server:
A single spindle A portion of a spindle One or more RAID arrays A meta of multiple RAID arrays
Array
LUN LUN
Array Array Array
LUN LUN
On the host machine, file systems can be created on LUNs. Network Attached Storage (NAS) appears to hosts as file systems (FS). Hosts access NAS storage via file based protocols (for example NFS).
10 IBM SAP DB2 Center of Excellence
Container 1
Container 2
Tablespace Tablespace
Container N
Container 1
Container 2
Container N
...
Container 1 Container 2
Tablespace
Container N
Put each container of a table space on a separate file system to maximize I/O parallelism (DB2 striping) Enable DB2_PARALLEL_IO for table spaces with one container per RAID device or stripe set For partitioned databases: Use dedicated LUNs/filesystems for each partition for easy problem determination.
11
Example:
Extentsize = 2 Number of containers = 4 Number of disks per container = 1 Prefetch size = 8 pages All disks are busy during for example a table scan.
How does DB2 determine the number of physical disks per container?
If DB2_PARALLEL_IO is not specified then number of physical disks per container defaults to 1. If DB2_PARALLEL_IO=* then number of physical disks per container defaults to 6. This is the number of disks that is frequently used in RAID5 devices. You may also explicitly specify the number of disks. For example DB2_PARALLEL_IO=*:3,1:4
Performance recommendations: Use separate disks for data and logging (e.g. RAID 5 for data and RAID1 for logging) Do not configure operating system I/O (e.g. swap space) on disks that are used for DB2 data or logging. Use SMS for temporary table spaces. SMS table spaces can shrink automatically.
13
Page Size
With Basis 6.40 all table spaces are installed with uniform page size 16k Reduces required number of bufferpools. More efficient usage of memory. Page size determines table space size limit (DB2 V8): 256Gb for 16k pages Size limit is per partition Put large fast growing tables into their own table spaces! DB2 9 provides large tablespace support (used by default with DB2 9): DB2 9 uses 6 byte RID: 4 byte page number, 2 byte slot number. SAP Business Warehouse indexes with large RIDs consume 10-15% more space on disk and in bufferpool compared to regular table spaces.
14
Extentsize
With SAP Basis 7.00 uniform extentsize of 2 is used (with Basis < 7.00 different extentsizes were used for different table spaces) Small extentsize reduces unused disk space for empty or very small tables. Small extentsize reduces unused disk space for Multi Dimensional Clustering tables (space usage of MDC tables depends on selected MDC dimensions and actual data in the table. Make sure to select appropriate MDC dimensions to keep amount of partially filled extents as low as possible).
1997 EAST
1997 1997 1998 1999 WEST WEST NORTH EAST MDC Table
1999 SOUTH
For each combination of MDC dimensions values at least one extent is allocated!
15
Region
Block Index
Follow SAP notes 584952 (DB2 V8), 899322 (DB2 9.1), and 1086130 (DB2 9.5) to initially configure database memory. Since DB2 9 you can use the Self Tuning Memory Manager. If STMM is activated, set DATABASE_MEMORY=<fixed value> to define an upper limit for the database memory (for 9.5 set INSTANCE_MEMORY=<fixed value> and DATABASE_MEMORY=AUTOMATIC) The STMM should not be used with multi-partition SAP BI/DB2 systems, if the partitions have different memory requirements.
16
Part 2
DB2 Database Layout for SAP Business Warehouse
Overview: SAP BW concepts Layout on single-partition systems Data Partitioning Feature How to determine the correct number of partitions Layout on multi-partition systems
17
SID#STABD SID#STABI
SID#ODSD SID#ODSI
18
SAP BW Queries
Typical SAP BW Query: How much Revenue was generated with Product X in Timeframe Y for each Customer?
SELECT C.name, SUM( Fact.Revenue ) FROM Fact F, Customer C, Product P, Time T WHERE F.key1 = C.key AND F.key2 = P.key AND F.key3 = T.key AND P.key = X AND T.key = Y GROUP BY C.name
19
Bufferpools
Create separate table spaces for large InfoCubes, PSAand ODS-Objects to simplify storage management
Small InfoCubes and Aggregates SID#FACTD, SID#FACTI PSA and ODS data SID#ODSD, SID#ODSI Tablespace for large InfoCubes, Aggregates PSA- and ODS-Objects .... BP_BW_16K 16 KB page size
Assign SAP BW table spaces with large tables (> 1 Mio records) to buffer pool BP_BW_16K
Database Partition 0
20 IBM SAP DB2 Center of Excellence 2008 IBM Corporation
21
Network
Presentation Layer
22
0 0
1 1
2 2
3 0
4 1
5 2
6 0
7 1
8 2
9 10 11 ... 0 1 2 ...
Partition 0
Partition 1
Partition 2
23
A coordinating agent splits the query into sub queries, one for each database partition. Each sub query only processes the subset of the table data that is located on a particular database partition. Advantages: Fast query response times Almost linear scalability A single query can be processed concurrently on multiple database servers No maintenance overhead (compared to for example range partitioning) Disadvantage: Degree of parallelism can not be changed easily (requires redistribution of tables)
2008 IBM Corporation
process
process
Database Partition 0
Database Partition 1
Fast Communication
24
Scalability factors for queries with long execution times (avg. execution time was 97 seconds on 4 database partitions): 1 -> 2 partitions: 2.04 1 -> 4 partitions: 4.11
# SAP BW Queries/hour
600 500 400 300 200 100 0 1 2 3 4 # Physical Database Partitions
BP Quality: 100%
100%
100%
99,5%
Linear Scalability
25
Measured Scalability
2008 IBM Corporation
26
...
Appl. Server N
Bufferpool IBMDEFAULTBP
Fast Communication
27
DB Server 1
Partition 0 (Administration Partition)
DB Server 2
Partition 1 (Data Partition)
DB Server 3
Partition 2 (Data Partition)
DB Server 16
Partition 15 (Data Partition)
DB Layout Consideration: Increased workload on DB Server 1 because master- and dimension data must be send to all other partitions for query processing. Statements are prepared on Server 1. => Partition 0 should have more CPUs than other partitions.
28
29
Backup Foils
30
Example:
Each container of a table space on a separate RAID device 6 disks per RAID device Table space 1 has 4 containers Table space 2 has 5 containers DB2_PARALLEL_IO = 1:6,2:6 => NUM_IOSERVERS = max (6*4, 6*5) = 30
31
Prefetching
There are two types of physical reads: 1. Synchronous Reads are scheduled directly by database agents. 2. Asynchronous Reads (prefetching) are performed by I/O Servers. Prefetching can be enabled during access plan creation or at runtime. Each prefetch request is broken into multiple I/O requests. Prefetch performance is influenced by PREFETCH SIZE, NUM_IOSERVERS and type of buffer pools (e.g. block based). SAP recommends to set PREFETCH SIZE and NUM_IOSERVERS to AUTOMATIC. In this case the prefetch size is calculated based on:
Extent Size Number of containers in the table space Setting of DB2_PARALLEL_IO
Block-based area
Buffer pool
Big block read Extent Page Trigger Point
32
or
Vectored read Prefetch Size Prefetch Size Prefetch Size Prefetch Size
ch Prefet
Trigger Point
ch Prefet
Trigger Point
ch Prefet
Trigger Point
ch Prefet
Trigger Point
ch Prefet