Index Jump Scans and Updated Rules for Optimal DB2 LUW Index ...

55 downloads 98 Views 12MB Size Report
DB2 LUW V10 introduces Index Jump Scans as a new, more efficient, index access ... leave the session well equipped to make optimal index design choices.
Index Jump Scans and Updated Rules for Optimal DB2 LUW Index Design Scott Hayes DBI Software Minneapolis, Milwaukee, & Chicago DB2 User Groups | Platform: IBM DB2 for LUW

Click to edit Master title style

Abstract Submitted to IDUG • DB2 LUW V10 introduces Index Jump Scans as a new, more efficient, index access method. This session will do a deep dive analysis of Index Jump Scans and related performance benefits. Science projects and case studies will be explored and updated index design guidelines will be offered. Consideration will be given to Index Compression benefits as well. Attendees will leave the session well equipped to make optimal index design choices. • Submitted Bullet Points are offered in the slide notes.

2

Click to edit Master title style

Agenda • How Indexes Work • How Index Jump Scans (are supposed to) Work • Case studies on Index Design using 12M Row Table and 11 Business Queries • Monitoring Index Activity, db2batch, & Explain

• Compression Results for Storage Size and Performance • The “New Rules” of for Index Design • Summary

3

Click to edit Master title style

B-Tree Index Structure LR

NLEVELS =3

LR LR

ROOT page Intermediate (non-leaf) pages Leaf Pages

LR PR

NLEAF = 5

Data Pages

CREATE UNIQUE INDEX EMPNOIX on EMPLOYEE (EMPNO); SELECT * FROM EMPLOYEE WHERE EMPNO = ‘000210’; LR + LR + LR to IX + (LR to Data + PR to Data) = ¼ or 25% miss ratio, or 100 – 25% = 75% Hit Ratio for the query (assumes IX pages in BP)

Click to edit Master title style

B-Tree Index Structure J-LR

NLEVELS =3

ROOT page Intermediate (non-leaf) pages

Jo-LR

Jone-LR

LR PR

LR LRPR

Jones-LR

LR PR

LR PR

Leaf Pages

LR PR

NLEAF = 20

Data Pages

CREATE INDEX LASTFIRSTIX on EMPLOYEE (LASTNAME, FIRSTNME); SELECT * FROM EMPLOYEE WHERE LASTNAME = ‘Jones’ and FIRSTNME LIKE ‘B%’ order by LASTNAME, FIRSTNME; 4X LR to IX + 6X LR to Data + 5X PR to Data, 5 Phys/10 Logical = 50% Miss Ratio, or 100 – 50% Miss Ratio = 50% Hit Ratio with 1 Sort

Click to edit Master title style

B-Tree Index Structure NLEVELS =3

J-LR

ROOT page Intermediate (non-leaf) pages

Jo-LR

Jone-LR

LR LR PR LR

Jones-LR

LR PR LR LR

Leaf Pages

NLEAF = 20

Data Pages

CREATE INDEX LASTFIRSTIX on EMPLOYEE (LASTNAME, FIRSTNME) CLUSTER; SELECT * FROM EMPLOYEE WHERE LASTNAME = ‘Jones’ and FIRSTNME LIKE ‘B%’ order by LASTNAME, FIRSTNME; 4X LR to IX + 6X LR to Data + 2X PR to Data, 2 Phys/10 Logical = 20% Miss Ratio, or 100 – 20% Miss Ratio = 80% Hit Ratio with 0 Sorts

Click to edit Master title style

B-Tree Index Structure NLEVELS =3

ROOT page Intermediate (non-leaf) pages Leaf Pages

NLEAF = 20

LEAF PAGE SCANS ARE EXPENSIVE!!! LR PR

LR LRPR LR

LR PR LR LR

LR PR

Data Pages

CREATE INDEX LASTFIRSTIX on EMPLOYEE (LASTNAME, FIRSTNME) CLUSTER; SELECT * FROM EMPLOYEE WHERE FIRSTNME LIKE ‘B%’; (20X LR to IX + 16X PR to IX) + (8X LR to Data + 4X PR to Data), 20 Phys/28 Logical = 71% Miss Ratio, or 100 – 71% Miss Ratio = 29% Hit Ratio

Click to edit Master title style

High Cost of Leaf Page Scans Illustrated…

Click to edit Master title style

INDEX JUMP SCANS NLEVELS =3

ROOT page Intermediate (non-leaf) pages Leaf Pages

NLEAF = 20

JUMP SCANS SKIP OVER PAGES LR PR

LR LRPR LR

LR PR LR LR

LR PR

Data Pages

CREATE INDEX FULLNAME on EMPLOYEE (LASTNAME, MIDINIT, FIRSTNME) SELECT * FROM EMPLOYEE WHERE LASTNAME = ‘BECK’ and FIRSTNME = ‘BETTY’ (No predicate on MIDINIT)

Click to edit Master title style

I love science projects!

10

Click to edit Master title style

11

Click to edit Master title style

Performance Science Project Table Statistics IDUG.WEBSITE_DATA_TB

6+ Years of Website Hit Data

ROWS / CARD

11,848,746

NPAGES (4K)

786,971 V9.7 / 788,604 V10

SIZE (MB)

3,074 (~3GB) V9.7 / 3,080 V10

LOCKSIZE

Row

COMPRESSION

No (will try YES later)

AVGROWSIZE

260

12

13

Click to edit Master title style

Performance Science Project Column Statistics WEBSITE_DATA_TB COLUMN

COLCARD

% TB CARD

AVG #RIDS Per Value

AVG COL LEN

NUM NULLS

ACTIONVERB

36

0

329,131

8

0

AUTHID

752

0

15,756

7

0

BYTESXFERD

188,417

1

62

9

2,956

CLIENTTYPE

4,481

0

2,644

98

2,077

DOMAINNAME

192,512

1

61

29

0

HITTIMESTAMP

7,066,789

59

1

10

0

IPADDR

16,000

0

740

11

0

PROTOCOL

57

0

207,872

13

5

REFERURL

17,665

0

670

28

5

TARGETFILE

143,865

1

82

31

0

WEBSTATUS

633

0

18,718

6

5

Click to edit Master title style

Interesting Values (High and Low Cards) TargetFile DomainName • /blog/rss/db2_performa nce_rss2.xml 1,129,163 hits, 9% • /blog/rss/db2nightshow _rss2.xml 446,984 hits, 3% • /db2nightshow/200910 22DB2Night04.wmv 6,743 hits,