• No results found

Attack of the Blob! (Managing BLOBs Within a DB2 Database)

N/A
N/A
Protected

Academic year: 2021

Share "Attack of the Blob! (Managing BLOBs Within a DB2 Database)"

Copied!
37
0
0

Loading.... (view fulltext now)

Full text

(1)

Michael Krafick [@mkrafick]

Sr. Database Administrator, Atlanta

Session Code: D05

Wed, May 14, 2014 (08:00 AM - 09:00 AM) | Platform: DB2 for LUW

(2)

Database & Server Environment

P6 570

4 CPU (8 Logical) CPU

32G Memory

1.2T over 4 HDISKS

AIX 6.0 | DB2 9.7

Server oversized for drastic growth

DB only 50G at moment

(3)

• Isolated active log directory

• 7300 connections, 4500 used at any time

• 14 separate application servers

• 350,000 transactions at peak hour

• 2.8M daily transactions

• 6300 unique users

(4)

3rd Party Software

• Sales and service software for banking

• 1600+ locations

• 10,500+ teammates

• Acts as a "Caching" system for this tool, queries mainframe backend

• First DB2 environment implementation

(5)

Data disk utilization doubles from 30-40% to 60-80%

with volume

Active log disk utilization 20% higher than data disk, can jump to 90-100%

Overall database BP Hit Ratio is 70-80%

No locking, lock escalations, or deadlocks

(6)

Root Cause

Database Agnostic Design

“Plopped in place” (same BP, tablespace, etc)

Some best practices not in place for OLTP

Our customization changed database behavior

Critical table contains a blob field (XML Data)

(7)

2012 IDUG pre-conference seminar:

DB2 for LUW Performance Workshop

Performance “How To’s” on DBI Website

http://www.dbisoftware.com/blog/db2_performance.php?cat=39

GET SNAPSHOT FOR DATABASE ON <DBNAME>

MONREPORT.DBSUMMARY Procedure

(8)

What is a BLOB?

Binary Large Object (BLOB)

Store large objects

Documents

Pictures

Voice

Mixed media

(9)

Like its name sake, can be big and slow

LOB data is not kept in the buffer pool but is read from disk

Additional I/O to fetch, insert, or update

32k Row Definition Limit

(10)

How Does DB2 Natively Handle Lobs?

Stored in a location separate from the table row that references them

*Graphic from IBM Info Center

(11)

CREATE TABLE EMPLOYEE

(EMPNO CHAR(6) NOT NULL PRIMARY KEY, FIRSTNME VARCHAR(12) NOT NULL,

MIDINIT CHAR(1) NOT NULL WITH DEFAULT, LASTNAME VARCHAR(15) NOT NULL,

WORKDEPT CHAR(3), PHONENO CHAR(4),

PHOTO BLOB(10M) NOT NULL NOT LOGGED COMPACT) IN RESOURCE

Example taken from: “LOB Column Considerations” in InfoCenter

(12)

How Does DB2 Natively Handle Lobs?

Example:

PHOTO BLOB(10M) NOT NULL NOT LOGGED COMPACT

Create LOB “as small as possible” when COMPACT

Default is NOT COMPACT

Performance impact when using COMPACT feature

(13)

“It can be impractical (and sometimes impossible) to include large data objects in base table rows” (32k limit)

*Quote and Graphic from IBM Info Center

(14)

Affect of BLOB (20 Minute interval)

Effect of Bottleneck Table - < 5000 Rows, flushed nightly

Direct reads = 233754

Direct writes = 174318

(8715 Minute)

Direct write elapsed time (ms) = 24593

Update/Insert/Delete statements executed = 93176

Log pages written = 88708

Number write log IOs = 78827

(15)

• DB2 logs each time it manipulates a LOB

• Do you really need the data if recovery is needed?

• Option: NOT LOGGED

Does not log changes to BLOBs

(16)

Stop the Note Taking and Chit Chat

For example:

CREATE TABLE EMPLOYEE

(EMPNO CHAR(6) NOT NULL PRIMARY KEY, FIRSTNME VARCHAR(12) NOT NULL,

MIDINIT CHAR(1) NOT NULL WITH DEFAULT, LASTNAME VARCHAR(15) NOT NULL,

WORKDEPT CHAR(3), PHONENO CHAR(4),

PHOTO BLOB(10M) NOT NULL NOT LOGGED) IN RESOURCE

Example taken from: “LOB Column Considerations” in InfoCenter

(17)

ROLLFORWARD RECOVERY

LOB data will be placed with binary zeros

Even if NOT LOGGED, LOB columns are shadowed to allow changes to be rolled back

Shadowing is a recovery technique in which current

storage page contents are never overwritten. That is, old, unmodified pages are kept as "shadow" copies. These

copies are discarded when they are no longer needed to support a transaction rollback. [*IBM Info Center]

(18)

Stop the Note Taking and Chit-Chat (PT 3)

If the LOB column is larger than 1 GB, logging must be turned off.

As a rule of thumb, you might not want to log LOB columns larger than 10 MB.

Take this into account on readable HADR standby.

(19)

Break into it's own tablespace and BP

Consideration: Is your LOB only a few K?

Improve speed, place small LOBs in formatted rows

Benefit: LOBs can be brought into memory

Benefit: LOBs are eligible for Row Compression

(20)

Side Note: Separate Tablespaces in Recovery

Break into it's own tablespace and BP

LOBs and long data can elongate restore times

Tablespace level restore:

Consider restoring only what you need, do you need the LOB’s?

NOT LOGGED option also improves speed

(21)

1 Step – Estimate Proper Size

Command:

ADMIN_EST_INLINE_LENGTH--(--column-name--)--->

(22)

Do the Two-Step

• Results of estimate:

Number: Size estimate for column length

NULL: Inputs are NULL

-1: Can not be inlined (Length)

-2: Inserted before 9.7, can not be determined

• May want to ORDER BY or MAX results

(23)

(Watch Row Size Limits)

Table 1. Row size limits

Page size Row size limit Inline length limit

4K 4005 4001

8K 8101 8097

16K 16 293 16 289

32K 32 677 32 673

*Graphic from IBM Info Center

(24)

Do the Two-Step

2

nd

Step – ALTER COLUMN and REORG Command:

ALTER TABLE <table> ALTER COLUMN <colname> SET INLINE LENGTH <value>

Command:

REORG TABLE <tablename> …. LONGLOBDATA

(25)

The INLINE will not take affect unless you REORG (LONGLOBDATA) or UPDATE

From Info Center: This parameter is required when converting existing LOB data into inline LOB data

No real benefit during routine REORG process*

(Time consuming and doesn't improve clustering)

*LONGLOBDATA option on tables with XML columns will reclaim unused space and shrink the XML object.

(26)

Put on After Burners!

NO FILE SYSTEM CACHING vs. FILE SYSTEM CACHING

From Info Center: Allows you to enable/disable non-buffered I/O on specific TS while avoid dependency on physical layout

Allows DBM to decide which is best to used buffered or non- buffered

Used in CREATE TABLESPACE or ALTER TABLESPACE statements

Use STMM on BP or increase by 10-20 percent and retest till optimized

(27)

Command:

Db2look –d <dbname> -l

(28)

I have caching? Yeah, uh ..

Command:

db2 "get snapshot for tablespaces on <dbname>" | grep -p caching

(29)

BLOBs need FS caching to improve performance

Normal Tables (and INLINE BLOBs) do not

If you reverse it, it could be the difference between:

A N D

(30)

Results – Performance Load Test

Direct reads = 233754 73471 68% Improvement

Direct writes = 174318 14008 91% Improvement

Direct write requests = 16213 262 98% Improvement

Direct write elapsed time (ms) = 24593 1622 93% Improvement

Log pages written = 88708 53642 Overall work drops

Log write time (sec.ns) = 89 76 Overall work drops

Number write log IOs = 78827 48354 Overall work drops

(31)

• Total Transactions Processed - 9% increase

• 20% of Total Transactions improved by 15-16%

• <1% (Quote "Very Very Few") of transactions

slowed down slightly

(32)

Results - Production

SQL exceeding 2 seconds on basic FETCH Drops from thousands to <50

97.93% drop - Execution time for UPDATE statements

Per 100 executions against problem table (0.436s to 0.009s)

81.7% drop - Execution time for SELECT statements

Per 100 executions against problem table (0.656s to 0.120s)

ZERO Lock Escalations per 1000 transactions

(33)

Write Rate: 70 % Improvement | Read Rate: 20% Improvement [How often we have to spin disk]

Write Transfer Size – 2.25x Improvement [More volume at one time]

Read Transfer Size – 25% Improvement [More volume at one time]

10-20% drop in disk utilization

(34)

Brand Spanking New developerWorks Article

www.ibm.com/developerworks/data/library/techarticle/dm-1403taming/index.html

(35)

Prashant Sogarwal

Stephanie Knight-Baker

Scott Hayes

(36)

Wait! There's more - Order now!

Regular guest blogger at Db2Commerce.com

Attack of the BLOB!

10 Minute Triage – Pt 1 and 2

DB2 and HACMP Failover

Automatic Storage Tablespaces (AST): Compare and Contrast to DMS

Row and Column Access Control (Column Masking)

(37)

Sr. Database Administrator, Atlanta [email protected]

Twitter: @mkrafick

Session Code: D05 Attack of the Blob!

(Managing BLOBs Within a DB2 Database)

Please fill out your session evaluation before leaving!

References

Related documents

&lt;join type&gt; join &lt;dimension table&gt; on &lt;joined columns&gt; where &lt;simple filters&gt; group by &lt;grouped columns&gt; having &lt;aggregate filters&gt; order

Oliver Kohl-Frey works as subject librarian for political science and as information literacy project coordinator at the University of Konstanz.. He holds a Masters in

&lt;SSRPMDESC:This is an example report template&gt; This table contains the currently enrolled users:&lt;br&gt;&lt;br&gt; &lt;SSRPMCOMP:Customized Enrolled users&gt;. This

s-process p-process Mass known Half-life known

+CBEDGF HJIKFLI ?© MKNGNGOP MJQMJR S0ODTF VUXWU... ¥¦ü!ޘ§XàKã9ðïòñfáXubÝá˜ê^áno¿ñ1ÝpiUñbâ6Þ ê‚ñbâ ðÜ$øeë3Bëm%Þx

“ the seven words of our LORD on

Presented at 2007 Academy of International Business Conference, Indianapolis, Indiana &amp; 2006 Strategic Management Society Conference, Vienna, Austria.. Thomas, Douglas E.,

To address these questions, the following goals were set: (a) to reproduce field explosions pertaining to primary blast injury as accurate as possible in a controlled