Top Banner
05/07/22 DB2 Pools…..or…… Where has all my storage gone? Thank you, Peter, Paul, and Mary
32
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Storage Usage

04/12/23

DB2 Pools…..or……Where has all my storage gone?

Thank you, Peter, Paul, and Mary

Page 2: Storage Usage

04/12/23 ©2005 BMC Software2

Topics covered in this presentation

› Virtual Storage Usage in DB2 for z/OS› The main DB2 Storage Pools› The EDM Pool, RID Pool and SORT Pool

– What they are used for and how do they work– How large do they need to be?– What happens if they are sized incorrectly– Monitoring Pool Usage– Impact of DB2 for z/OS V8 and 64 bit addressing– Recommended Practices, Hints and Tips

Page 3: Storage Usage

04/12/23 ©2005 BMC Software3

Bars and Lines (not to scale)

64 bits - 16Eb

24 bits - 16Mb

32 bits - 4Gb31 bits - 2Gb

49 bits - 512Tb

The Line

The BarWasted

Below the Line

Above the Line

ReservedFor System

User AreaAbove the Bar

You can now address 8.6Billion times as much storage…

Another way of looking at it:

If 2Gb represents 1 secondThen 16Eb is over 272 years!

Page 4: Storage Usage

04/12/23 ©2005 BMC Software4

What comes next?

› Kilobyte 10 power of 3› Megabyte 10 power of 6› Gigabyte 10 power of 9 › Terabyte 10 power of 12› Petabyte 10 power of 15› Exabyte 10 power of 18› Zettabyte 10 power of 21› Yottabyte 10 power of 24

Also have Mebibyte for exact power of 2 (1,048,576) etc.

Page 5: Storage Usage

04/12/23 ©2005 BMC Software5

Where DB2 Storage is allocated

› Locks Stored in IRLM› Most of the rest comes out of DBM1

– Limited to 2Gb below line before V8• Significant VSC (Virtual Storage Constraint)

– Some relief available by using Data Spaces and/or Hiperpools – Much more help in V8 using 64 bit addressing

› Many conflicting demands for limited resource– Results in a juggling act at many sites– Primary motivator for many early V8 adopters

• VSCR in CMPAT mode – Excellent resources available with more detail on DB2 Virtual Storage

Management• See John Campbell’s excellent paper on this topic

– ftp://ftp.software.ibm.com/software/data/db2zos/DB2VSTORprez.pdf

Page 6: Storage Usage

04/12/23 ©2005 BMC Software6

Mainframe Technology EvolutionI/O is the Laggard

› I/O remains very slow in computing terms– I/O Performance hasn’t improved as quickly as other areas

› If we compare improvements over the past 10 years:CPU 374 mips 17,802 mips x 48Real Storage 8Gb 512Gb x 64DB Size 200 Gb 20 Tb x 100I/O time 30ms 2-3ms x 10-15

› DB2 uses Virtual Storage to reduce I/O and improve performance

Page 7: Storage Usage

04/12/23 ©2005 BMC Software7

Below the Line Storage

› Used to be the major problem› Still some storage areas below the line

– 600Kb base requirement– 800 bytes per Active thread– 300 bytes (V7) or <20 bytes (V8) per Open Dataset

› Major consequence is DSMAX– Theoretical limit was 32K (V7) – now 100K in V8– Practical V7 limit more likely to be mid-20’s– Problem for ERP systems and multi-partitioned objects

› All above assumes SWA is above the line– If not, DSMAX will need to be 5,000 or less, even in V8

Page 8: Storage Usage

04/12/23 ©2005 BMC Software8

DB2 Virtual Storage Map (V7)

Page 9: Storage Usage

04/12/23 ©2005 BMC Software9

DB2 Virtual Storage Map (V8)

Page 10: Storage Usage

04/12/23 ©2005 BMC Software10

Where Has All My Memory Gone?

Much of it has gone to pools

EDM PoolRID Pool

Sort Pool

Bufferpool

Bufferpools - Cache for data and index pagesEDM Pool - Cache for access paths and related

data such as DBDsRID Pool - Cache to prevent unnecessary I/O SORT Pool - Internal Sortwork area (per Sort)

Page 11: Storage Usage

04/12/23 ©2005 BMC Software11

DB2 Pool Sizing (EDM, RID, and SORT)DSNZPARM Settings

Page 12: Storage Usage

04/12/23 ©2005 BMC Software12

EDM Pool ManagementNuts and Bolts

›Caches access path & internal structure definitions›This pool contains

–DBDs – database descriptors–Skeleton Package and Cursor Tables

(SKPT & SKCT)–Package and Cursor Tables – (PT/CT)–Authorization cache block for each

plan (optional)• Except those with CACHESIZE(0)

–Skeletons of dynamic SQL for CACHE DYNAMIC SQL (optional)

• Could be in data space (VSCR in V7)–Trigger Packages

EDM Pool

DBD DBD SKPT

SKCT SKCT

SKPT

CT

CT

CT

CT

CTPT CT

DS DS DS

DB2 Database Services

DBM1

Page 13: Storage Usage

04/12/23 ©2005 BMC Software13

Consequences if sized incorrectly

› Too Small– Increased I/O against Directory

• DBD01, SPT01, SCT02– Response time degradation due to increased I/O– Increased CPU (e.g. Auth check if SKCT continually stolen)– Re-preparation of Dynamic SQL– Fewer Concurrent Threads

› Too Large– Wasted storage that could be better used elsewhere

Page 14: Storage Usage

04/12/23 ©2005 BMC Software14

Obtaining Space in EDM Pool

› Available– Any unused Storage– Old CTs and PTs (Completed URIDs)

› Stealable– SKCTs and SKPTs (Cached Copies for future use)– Inactive DBDs

› Not Available– DBDs that are being used by a URID– CTs and PTs for Active URIDs (Application Copies)

› LRU used for Available then Stealable Storage– If no Space is available you get a -904 with RC 00C90089

Page 15: Storage Usage

04/12/23 ©2005 BMC Software15

Best Fit or First Fit for Allocating Spacein the EDM Pool

› Controlled by DSNZPARM setting EDMBFIT– Only applies to EDM Pools bigger than 40Mb– Default is EDMBFIT = No (like previous releases)

› EDMBFIT = No– Uses first available space in LRU chain for any object– Fragments Storage but better for performance

› EDMBFIT = Yes– Continues to look for ideal space for required object– Provides optimal Storage use for VSCR systems…– Cost is CPU (free Chain Search) and Latch Contention

Page 16: Storage Usage

04/12/23 ©2005 BMC Software16

BIND Options

› ACQUIRE(USE) vs ACQUIRE(ALLOCATE)– USE requires less space in the EDM Pool (check PLSIZE)– ALLOCATE uses more resources at Bind Time– ALLOCATE also turns off selective partition locking

› RELEASE(COMMIT) vs RELEASE(DEALLOCATE)– COMMIT reduces strain on EDM Pool by freeing CTs earlier– But it can have a considerable impact on Performance

• e.g. Index Lookaside and Sequential Detection Counters reset – Consider COMMIT for Infrequently used Packages?

› DEGREE(ANY) vs DEGREE(1)– DB2 keeps two access paths in Plan in case of fallback– Check using AVGSIZE column in SYSPLAN or SYSPACKAGE

Page 17: Storage Usage

04/12/23 ©2005 BMC Software17

Some points to consider…

› Storage Requirement grows each release of DB2– Especially for DB2 V8 (Unicode, Long Names) but 64 bit helps

› Don’t use 1 plan for batch and 1 for online– Even with Packages the search time could cause problems– Difficult to diagnose problems– Copy of Plan Header gets loaded into EDM Pool for each User

› Auth Cache is stored in the EDMPOOL SKCT– If your Plans are Granted to Public why waste the space?

› Put Global DSC in Data Space for DB2 V7– Provides immediate VSCR and allows larger Cache

Page 18: Storage Usage

04/12/23 ©2005 BMC Software18

… more points

› Java requires program to retrieve data definition– Provided by DSNZPARM DESCSTAT– Increases EDM Pool size

› If EDM Pool size is a problem consider CONTSTOR– DSNZPARM introduced by PQ14391– Contracts Thread Storage after 50 commits or if it gets >1Mb– Downside is CPU cost of doing this – main purpose is VSCR

› EDM Pool for Data Sharing likely to be 10% larger– DDL invalidates DBD in other ssid EDM Pools– Loaded again the next time it is needed– In-flight URIDs require old copy – result is >1 copy in EDM Pool

› All objects loaded into EDM Pool use BP0

Page 19: Storage Usage

04/12/23 ©2005 BMC Software19

How to Monitor the EDM Pool

› All these numbers are available using most Performance Monitors or via the DB2 Accounting and Statistics traces

› Monitor Free Pages in Chain– Only reduce EDM Pool size if consistently >20% pool size

› Fails due to Pool Full should be zero– Any non zero figure is an application failure and impacts a user

› Ratio of Loads of Package & Cursor Sections, DBDs from Pool vs from DASD

– Ideally should be above 80% for most systems

Page 20: Storage Usage

04/12/23 ©2005 BMC Software20

EDM Pool ManagementDynamic SQL Cache – What’s it like

› Cached Statements – Details on statement (text and such)– Significant reduction in overhead in heavy

dynamic environments where same SQL statement may be executed many times.

– Increases overall size for EDM Pool• Specify a dataspace for holding the SQL in

V7 environments– Skeletons moved to dataspace

• No issues in DB2 V8 – Cache above the bar

Page 21: Storage Usage

04/12/23 ©2005 BMC Software21

Changes in DB2 V8

› EDM Pool split into 3 components– DBD Pool - only for DBDs (above Bar)– Statement Pool - SKPTs for Dynamic SQL (above Bar)– EDM Pool - for remaining data (still below Bar)

› DBDs are always in V8 Format in DBD Pool– Even in Compat Mode– Use Unicode and Long Names - usually larger– In ENFM and NFM they are stored in Directory in V8 Format– In Compat mode they are written in V7 Format

› Using Online Schema causes DBD to grow

Page 22: Storage Usage

04/12/23 ©2005 BMC Software22

RID Pool ManagementNuts and Bolts

RID Pool› RID pool used more than you might think– List Prefetch – Multi-Index Access – Hybrid Join– Enforce Unique keys when updating multiple rows

› Optimizer looks at RID Pool size– If it estimates SQL will use >50% pool it won’t use RIDS

› If no space or SQL breaks limits it reverts to a TS scan– 25% of the rows in the table (minimum 4,075)– 16 million RIDS

› Consider using REOPT(VARS)

Page 23: Storage Usage

04/12/23 ©2005 BMC Software23

Sizing and Storage Allocation

› Default size 4Mb– Maximum is 1,000Mb (V7)– Defined by MAXRBLK DSNZPARM

› Created at DB2 start up but no space allocated– Allocated in 16K blocks (V7)– Each block holds 4,075 4-byte RIDS

› Storage Requirement can quickly get quite large– 1 million 5-byte RIDs requires almost 5Mb of RID Pool– And you need twice this if you’re Sorting RIDs

› A single user can use whole Pool at execution time – Size as large as you can given VSCR and monitor

Page 24: Storage Usage

04/12/23 ©2005 BMC Software24

RID Pool ManagementKey Metrics

RID Pool

Exceeded RDS LimitMore that 25% of table rows being accessed

Exceeded DM LimitMore that 16 Million RIDS being processed

No Storage AvailableNumber of failures – incremented each time a process using RID fails due to lack of space

Need a different access path

Allocate more space to the RID Pool

Space Allocated – High Water and CurrentSpace Allocated as needed up to MAXRBLK

Page 25: Storage Usage

04/12/23 ©2005 BMC Software25

What changes in DB2 V8

› Partial 64 bit exploitation support provided› RID Pool split into 2 sections

– RID Map below Bar – probably 90% smaller than V7– RID Lists stored Above Bar

› Maximum size increased to 10Gb– 25% Below Bar and 75% Above it

› RID Block size now 32K› Each RID List can handle double number of RIDs

– Approx 26 million before RID access disabled

Page 26: Storage Usage

04/12/23 ©2005 BMC Software26

How DB2 Sorts data

› DB2 uses a Sort Algorithm called a Tournament Sort– This has been built into the Hardware Microcode– Provides DB2 with highly efficient Sorts

ABLEDELTAZULUBAKERMIKECHARLIEX-RAY

ABLEDELTAMIKEZULU

BAKERCHARLIE

X-RAY

ABLEBAKERCHARLIEDELTAMIKEX-RAYZULU

Page 27: Storage Usage

04/12/23 ©2005 BMC Software27

The Tournament Sort

1.Input data read into the leaf pages of a tree structure› At each level of the tree the data is compared to it’s neighbour› The ‘Winner’ (lowest value for an Ascending Sort) moves up the tree› At the top of the tree the sorted entries are placed into Runs› Winning entries are then removed from the tree and the next value inserted

2. If >1 Run is generated then get a Merge phase› Each Run is in sequence but they have to be merged together

Page 28: Storage Usage

04/12/23 ©2005 BMC Software28

What gets Sorted?

› All Selected Columns plus Sort KeySELECT C1, C2, C3, C4, C5…ORDER BY C2, C4

Sort Record is C2, C4, C1, C2, C3, C4, C5› VARCHAR padded to full length + length indicator› Null Fields include Null indicator› If LOB column is Selected DB2 Sorts a 51 byte pointer› Add 16 bytes for interface to Hardware Sort capability› Total Sort record is rounded up to a Half Word Boundary

Page 29: Storage Usage

04/12/23 ©2005 BMC Software29

Reduce Data to be Sorted

› If Sorted Record > 4075 bytes DB2 uses a TAG SORT– Data to be sorted placed directly into 32K Workfile Database– Sorts the keys plus the Address (RID) of the data– Retrieves Data using RID resulting from Sort

› If Sort fits into SORTPOOL no Temp Database required› Both big performance hits so only sort what’s needed› Don’t select unnecessary columns

– Why Select a column in the WHERE Clause with = predicate?SELECT C1, C2, C3FROM TABLE WHERE C1 = ‘CUSTOMER’

Page 30: Storage Usage

04/12/23 ©2005 BMC Software30

Workfile Database

› Sorts that don’t fit in SORTPOOL overflow here› DSNDB07 for non-Data Sharing systems› Ensure it has it’s own dedicated Bufferpool

– Set VPSEQT = 90-95% (not entirely sequential)– Set VDWQT & DWQT high (90%) - want to keep pages in Pool

› Should be at least 5 Workfiles– All same size as allocated in rotation– Don’t use Secondary

• It will all get used anyway› Make sure you have a 32K workfile for big sorts

Page 31: Storage Usage

04/12/23 ©2005 BMC Software31

Monitoring SORT

› Check Accounting and Statistics Reports– Merge Passes Degraded Low Buffers / Merge Passes Requested

• Indicates Sort Prefetch has been reduced due to Buffer Shortage– Workfile Request rejected Low Buffers / Workfile Requests

• Reduced degree of Parallel Merge due to Buffer Shortage – Workfile Requests for Merge Pass / Merge Passes Requested

• If low this tells you on average your SORT Pool is probably OK› As with all Statistics remember you can get anomalies› Check Workfile Bufferpool Statistics (easiest if BP7)

– Should have Very High Sequential activity– High numbers of Synchronous reads indicates problems

› Detailed information by thread in IFCID 95 and 96

Page 32: Storage Usage

04/12/23 ©2005 BMC Software32

Changes in DB2 V8

› Sort Tree Nodes go above the Bar– Bottom Level of Sort tree containing the full Sort Data– By far the largest Storage requirement of a Sort

› Still some SORTPOOL space below the Bar– Remaining elements of the Sort Tree– Pointers to the data above the Bar

› Will provide considerable relief from Sort Storage problems› Reduces overflows into Workfile database› Maximum Sort Key size 16,000 bytes from 4,000