Go-Faster Consultancy Ltd.1 Single Table Clusters, an alternative to partitioning? David Kurtz Go-Faster Consultancy Ltd.

Slides:



Advertisements
Similar presentations
1 Concurrency: Deadlock and Starvation Chapter 6.
Advertisements

Slide 1Fig 26-CO, p.795. Slide 2Fig 26-1, p.796 Slide 3Fig 26-2, p.797.
& dding ubtracting ractions.
Copyright © 2003 Pearson Education, Inc. Slide 1 Computer Systems Organization & Architecture Chapters 8-12 John D. Carpinelli.
Chapter 1 The Study of Body Function Image PowerPoint
1 Copyright © 2013 Elsevier Inc. All rights reserved. Chapter 3 CPUs.
Properties Use, share, or modify this drill on mathematic properties. There is too much material for a single class, so you’ll have to select for your.
Multiplication X 1 1 x 1 = 1 2 x 1 = 2 3 x 1 = 3 4 x 1 = 4 5 x 1 = 5 6 x 1 = 6 7 x 1 = 7 8 x 1 = 8 9 x 1 = 9 10 x 1 = x 1 = x 1 = 12 X 2 1.
Division ÷ 1 1 ÷ 1 = 1 2 ÷ 1 = 2 3 ÷ 1 = 3 4 ÷ 1 = 4 5 ÷ 1 = 5 6 ÷ 1 = 6 7 ÷ 1 = 7 8 ÷ 1 = 8 9 ÷ 1 = 9 10 ÷ 1 = ÷ 1 = ÷ 1 = 12 ÷ 2 2 ÷ 2 =
1 Hyades Command Routing Message flow and data translation.
Refreshing Materialized Views
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Properties of Real Numbers CommutativeAssociativeDistributive Identity + × Inverse + ×
CALENDAR.
Mean, Median, Mode & Range
FACTORING ax2 + bx + c Think “unfoil” Work down, Show all steps.
Year 6 mental test 5 second questions
Year 6 mental test 10 second questions
Chapter 6 File Systems 6.1 Files 6.2 Directories
1 Chapter 12 File Management Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design Principles,
£1 Million £500,000 £250,000 £125,000 £64,000 £32,000 £16,000 £8,000 £4,000 £2,000 £1,000 £500 £300 £200 £100 Welcome.
REVIEW: Arthropod ID. 1. Name the subphylum. 2. Name the subphylum. 3. Name the order.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Introduction to SQL Tuning Brown Bag Three essential concepts.
13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.
Database Performance Tuning and Query Optimization
Randomized Algorithms Randomized Algorithms CS648 1.
Briana B. Morrison Adapted from William Collins
Look at This PowerPoint for help on you times tables
11 Copyright © Oracle Corporation, All rights reserved. Managing Tables.
9 Copyright © 2004, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
Hash Tables.
MySQL Access Privilege System
Microsoft Access.
Go-Faster Consultancy Ltd.1 Experiences of Global Temporary Tables in Oracle 8.1 David Kurtz Go-Faster Consultancy Ltd.
1 Further Experiences of Global Temporary Tables in Oracle 8.1 David Kurtz Go-Faster Consultancy Ltd.
Vanderbilt Business Objects Users Group 1 Reporting Techniques & Formatting Beginning & Advanced.
Module 10: Virtual Memory
Chapter 10: Virtual Memory
VOORBLAD.
8 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Using Explicit Cursors.
Chapter 6 File Systems 6.1 Files 6.2 Directories
Copyright © 2012, Elsevier Inc. All rights Reserved. 1 Chapter 7 Modeling Structure with Blocks.
Factor P 16 8(8-5ab) 4(d² + 4) 3rs(2r – s) 15cd(1 + 2cd) 8(4a² + 3b²)
Basel-ICU-Journal Challenge18/20/ Basel-ICU-Journal Challenge8/20/2014.
1..
© 2012 National Heart Foundation of Australia. Slide 2.
Lets play bingo!!. Calculate: MEAN Calculate: MEDIAN
Understanding Generalist Practice, 5e, Kirst-Ashman/Hull
Before Between After.
Model and Relationships 6 M 1 M M M M M M M M M M M M M M M M
25 seconds left…...
Global Payroll Performance Optimisation - I David Kurtz Go-Faster Consultancy Ltd.
Subtraction: Adding UP
Equal or Not. Equal or Not
Slippery Slope
Januar MDMDFSSMDMDFSSS
We will resume in: 25 Minutes.
©Brooks/Cole, 2001 Chapter 12 Derived Types-- Enumerated, Structure and Union.
1 Lesson Dividing with Integers. 2 Lesson Dividing with Integers California Standard: Number Sense 2.3 Solve addition, subtraction, multiplication,
Intracellular Compartments and Transport
PSSA Preparation.
& dding ubtracting ractions.
Essential Cell Biology
Foundations of Data Structures Practical Session #7 AVL Trees 2.
Presentation transcript:

Go-Faster Consultancy Ltd.1 Single Table Clusters, an alternative to partitioning? David Kurtz Go-Faster Consultancy Ltd.

Go-Faster Consultancy Ltd.2 Who am I? DBA –Independent Consultant –Performance Tuning

Go-Faster Consultancy Ltd.3 What is this all about? A single table cluster Why it reduced contention? Why it worked on the test system? Why it failed on the production system?

Go-Faster Consultancy Ltd.4 What was our environment? Swiss Payroll System –Retrospective (not like P.A.Y.E.) Oracle bit –Rule Based Optimiser –Now HP-UX ,000 employees

Go-Faster Consultancy Ltd.5 How many values are calculated? –100 values / employee / month retained Writes 3.5M values to balance table –78 million rows on balance table –(after 20 months)

Go-Faster Consultancy Ltd.6 How is payroll calculated? There are 2 ways to do payroll –Process employees sequentially Calculate each rule for each employee –Set processing Rule A+B=C INSERT INTO C(EMPNO, VALUE) SELECT E.EMPNO, A.VALUE+B.VALUE,... FROM tableA, tableB, elig E WHERE A.EMPNO = E.EMPNO AND B.EMPNO = E.EMPNO

Go-Faster Consultancy Ltd.7 Payroll Process Design Each employee allocated to pay group pay group = MOD(emplid,14)+1 All employees in each pay group calculated simultaneously using set processing Each pay group allocated to a payroll process Process 14 pay groups in parallel Process do not lock each other out

Go-Faster Consultancy Ltd.8 Payroll Process Design Single balance table For each month for each retro date –Deletes all pay element rows for eligible employees –Recalculate –Insert freshly calculated rows

Go-Faster Consultancy Ltd.9 Effects of streaming 14 processes concurrently deleting from and inserting in the same balance table. 14 updates to the same block 14 versions of the block in the rollback segment Recalculation process reads rows from balance table from previous month

Diagram from Oracle Concepts Manual10 ORA-1555 Snapshot Too Old Start a long running query Update a data block used by that query Commit the update Other updates spin the rollback segments

Go-Faster Consultancy Ltd.11 ORA-1555 Snapshot Too Old Long running query on balance table as part of calculation Deletes in other streams Huge rollback segments (to avoid ORA- 1555) –15 x 2100Mb segments SET TRANSACTION USE ROLLBACK SEGMENT

Diagram From Oracle Concepts Manual12 Rollback segment contention Read Consistency Navigate the rollback segment block header chain to the version of the data block that was current when the query started.

Go-Faster Consultancy Ltd.13 Rollback segment contention Navigation of segment block header chain CPU intensive Re-read rollback segment blocks from disk that have been aged out of the block buffer cache.

Go-Faster Consultancy Ltd.14 How to avoid inter-process contention? Avoid updating a data block in one process while it referencing/updating it in another. Make sure that data for different streams is in different data blocks How about partitioning the data?

Go-Faster Consultancy Ltd.15 Partitioning Range Partition (Oracle 8.0) Hash Partition (Oracle 8.1) –(Hash within a range) We considered changing the mod(,14) function to hash(,14) BUT, partitioning invokes the Cost Based Optimiser.

Diagram From Oracle Concepts Manual16 Clustering

Go-Faster Consultancy Ltd.17 Clustering Physically arranges the data within a table. Define a cluster key All rows that have the same cluster key values are kept together Old technology - dates back to Oracle 6 can still used Rule Based Optimiser

Go-Faster Consultancy Ltd.18 Clustering All rows that have the same cluster key values are kept together –All the rows in any one block share the same cluster key Rows with different cluster key values must exist in different blocks.

Go-Faster Consultancy Ltd.19 Clustered Balance Table by Employee ID Inter-process contention disappeared –Each block contained rows for one and only one employee ID –Although one emplid may actually be stored in many blocks. Rollback HWMs dropped

Go-Faster Consultancy Ltd.20 Performance Metrics

Go-Faster Consultancy Ltd.21 When are clusters faster? For a single threaded process, inserting/deleting a cluster was slower than similar heap table. Clusters faster when 3 or more processes in parallel updating a single clustered table.

Go-Faster Consultancy Ltd.22 Clustered Balance Table by Employee ID) Unique index not used (unless hinted) Considered dropping it –Application design permitted it So after successful testing we planned to put it in production

Go-Faster Consultancy Ltd.23 And when we moved it to production... Disaster 50% INCREASE in execution time big jump in I/O Why?

Go-Faster Consultancy Ltd.24 A simple example create table heap_t1 (key integer, counter integer, value varchar2(50) ); create cluster clus_1 (key integer); create index clus_1 on cluster clus_1; create table clus_t1 (key integer, counter integer, value varchar2(50) ) cluster clus_1 (key);

Go-Faster Consultancy Ltd.25 cluster key values each declare l_counter integer := 0; l_string varchar2(50) := 'zero'; begin loop l_string := RPAD(l_string,50,'.'); insert into heap_t1 (key,counter,value) values (MOD(l_counter,10), l_counter, l_string); insert into clus_t1 (key,counter,value) values (MOD(l_counter,10), l_counter, l_string); insert into heap_t2 (key,counter,value) values (TRUNC(l_counter/200), l_counter, l_string); insert into clus_t2 (key,counter,value) values (TRUNC(l_counter/200), l_counter, l_string); l_counter := l_counter + 1; exit when l_counter >= 2000; l_string := TO_CHAR(TO_DATE(l_counter,'j'),'jsp'); end loop; commit; end; /

Go-Faster Consultancy Ltd.26 Which key values are in which block? selectblk_no, key, count(*) from(selectkey,counter,dbms_rowid.rowid_relative_fno(rowid) file_no,dbms_rowid.rowid_block_number(rowid) blk_no,dbms_rowid.rowid_row_number(rowid) row_no fromheap_t1 ) group by blk_no, key ;

Go-Faster Consultancy Ltd.27 Key = mod(n,10) Heap BLK_NO KEY CNT Cluster BLK_NO KEY CNT

Go-Faster Consultancy Ltd.28 Key = TRUNC(n/200) Heap BLK_NO KEY CNT Cluster BLK_NO KEY CNT ;

Go-Faster Consultancy Ltd.29 Why did the behaviour change? Test System – 7 blocks / emplid Production (at time of move) –10 blocks / emplid mutliblock_read_count = 8 2 I/Os to read all blocks for an emplid indicated by cluster key

Go-Faster Consultancy Ltd.30 Solution Cluster key on two columns –emplid, –curr_pay_end_dt If blocks/key << 1 –space wastage –increase I/O

Go-Faster Consultancy Ltd.31 Performance Metrics

Go-Faster Consultancy Ltd.32 Moral of the story Make sure you test environment accurately mirrors production –Now –AND FOR THE FUTURE

Go-Faster Consultancy Ltd.33 What actually happened next? Upgraded to Oracle Global Temporary Tables Developed incremental processing Retro-date changed to –thus reducing the processing It has now changed again to New payroll system being implemented

Go-Faster Consultancy Ltd.34 Related Reading Causes of ORA Oracle Scene Jonathan Lewis, Practical Oracle 8i Dan Hotka’s Geeky Block Internals presentations –UKOUG 1999 & 2000

Go-Faster Consultancy Ltd.35 Questions?

Go-Faster Consultancy Ltd.36 Single Table Clusters, an alternative to partitioning? David Kurtz Go-Faster Consultancy Ltd.