m.kersten 2008 1 monetdb, cracking and recycling martin kersten cwi amsterdam

89
M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

Upload: roger-simon

Post on 19-Jan-2016

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008 1

MonetDB, Cracking and recycling

Martin KerstenCWI

Amsterdam

Page 2: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008 2

Try to maximize performance

Paste

Present

Potency

CrackingB-tree, HashIndices

MaterializedViews

Page 3: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008 3

• Indices in database systems focus on:

• All tuples are equally important for fast retrieval

• There are ample resources to maintain indices

• MonetDB cracks the database into pieces based on actual query load

Find a trusted fortune teller

Page 4: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking algorithms

Physical reorganization happens per column based on selection predicates.

Split a piece of a column in two new pieces

A<10

A>=10

A<10

Page 5: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking algorithms

Physical reorganization happens per column

Split a piece of a column in two new pieces

Split a piece of a column in three new pieces

A<10

A>=10

A<10

5<A<10

A>=10

5<A<10

A<5

Page 6: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

12

13

4

17

15

select A>5 and A<10

Page 7: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12

Page 8: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12 >=10

>=10

Page 9: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12

>=10

Page 10: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12

>=10

<=5

Page 11: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12

>=10

<=5

Page 12: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12

>=10

<=5

Page 13: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12

>=10

<=5

Page 14: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12

>=10

Page 15: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12

>=10

Page 16: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12

<=5

Page 17: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12

<=5

<=5

Page 18: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12

<=5

>5 and <10

Page 19: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6 2

15

13

4

17

12

<=5

>5 and <10

Page 20: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6 2

15

13

4

17

12

<=5

>5 and <10

Page 21: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12

<=5

>5 and <10

Page 22: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12

>5 and <10

Page 23: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

13

4

17

12

<= 5

>= 10

> 5

15

Page 24: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12

<= 5

>= 10

> 5

Improve data access for

future queries

Page 25: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12

<= 5

>= 10

> 5

Improve data access for

future queries

select A>3 and A<14

Page 26: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12

<= 5

>= 10

> 5

Improve data access for

future queries

select A>3 and A<14

3

8

6

2

15

13

4

17

12

<= 5

>= 10

> 5

Page 27: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12

<= 5

>= 10

> 5

Improve data access for

future queries

select A>3 and A<14

3

8

6

2

15

13

4

17

12

<= 5

>= 10

> 5

Page 28: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12

<= 5

>= 10

> 5

Improve data access for

future queries

select A>3 and A<14

3

8

6

2

15

13

4

17

12

<= 5

>= 10

> 5

Page 29: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

racking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12

<= 5

>= 10

> 5

Improve data access for

future queries

select A>3 and A<14

3

8

6

2

15

13

4

17

12

<= 5

>= 10

> 5

>3 and <14

<=3

Page 30: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12

<= 5

>= 10

> 5

Improve data access for

future queries

select A>3 and A<14

3

8

6

2

15

13

4

17

12

<= 5

>= 10

> 5

>3 and <14

<=3

Page 31: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12

<= 5

>= 10

> 5

Improve data access for

future queries

select A>3 and A<14

3

8

6

2

15

13

4

17

12

<= 5

>= 10

> 5

>3 and <14

<=3

Page 32: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12

<= 5

>= 10

> 5

Improve data access for

future queries

select A>3 and A<14

3

8

6

2

15

13

4

17

12

<= 5

>= 10

> 5

>3 and <14

<=3

Page 33: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12

<= 5

>= 10

> 5

Improve data access for

future queries

select A>3 and A<14

3

8

6

2

15

13

4

17

12

<= 5

>= 10

> 5

<=3

Page 34: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12

<= 5

>= 10

> 5

Improve data access for

future queries

select A>3 and A<14

3

8

6

2

15

13

4

17

12

> 3

>= 10

> 5

<=3

Page 35: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12

<= 5

>= 10

> 5

Improve data access for

future queries

select A>3 and A<14

3

8

6

2

15

13

4

17

12

> 3

>= 10

> 5

<=3

Page 36: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12

<= 5

>= 10

> 5

Improve data access for

future queries

select A>3 and A<14

3

8

6

2

15

13

4

17

12

> 3

>= 10

> 5

<=3

Page 37: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12

<= 5

>= 10

> 5

Improve data access for

future queries

select A>3 and A<14

3

8

6

2

15

13

4

1712

> 3

>= 10

> 5

<=3

Page 38: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12

<= 5

>= 10

> 5

Improve data access for

future queries

select A>3 and A<14

3

8

6

2

15

13

4

1712

> 3

>= 10

> 5

<=3

Page 39: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12

<= 5

>= 10

> 5

Improve data access for

future queries

select A>3 and A<14

3

8

6

2

15

13

4

17

12

> 3

>= 10

> 5

<=3

Page 40: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12

<= 5

>= 10

> 5

Improve data access for

future queries

select A>3 and A<14

3

8

6

2

15

13

4

17

12

> 3

>= 10

> 5

<=3

Page 41: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12

<= 5

>= 10

> 5

Improve data access for

future queries

select A>3 and A<14

3

8

6

2

15

13

4

17

12

> 3

>= 10

> 5

<=3

Page 42: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12

<= 5

>= 10

> 5

Improve data access for

future queries

select A>3 and A<14

3

8

6

2

15

13

4

17

12

> 3

>= 14

> 5

<=3

>=10

Page 43: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12

<= 5

>= 10

> 5

Improve data access for

future queries

select A>3 and A<14

3

8

6

2

15

13

4

17

12

> 3

>= 14

> 5

<=3

>=10

Page 44: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Cracking example

3

8

6

2

15

13

4

17

12

select A>5 and A<10

3

8

6

2

15

13

4

17

12

<= 5

>= 10

> 5

Improve data access for

future queries

select A>3 and A<14

3

8

6

2

15

13

4

17

12

>3

>= 14

> 5

<=3

>=10

The more we crack the more

we learn

Page 45: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Design

The first time a range query is posed on an attribute A, a cracking DBMS makes a copy of column A, called the cracker column of A A cracker column is continuously physically reorganized based on queries that need to touch attribute such as the result is in a contiguous space

For each cracker column, there is a cracker index

Cracker Index

Cracker Column

Page 46: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

A simple range queryTry to avoid useless investments

Page 47: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

TPC-H query 6

Try to avoid useless investments

Page 48: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008 48

• Cracking is easy in a column store and is part of the critical execution path

• Cracking works under high volume updates

Try to avoid useless investments

Page 49: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Updates

Base columns are updated as normally

We need to update the cracker column and the cracker index

Efficiently

Maintain the self-organization properties

Two issues: When How

Page 50: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

When to propagate updates in cracking

Follow the workload to maintain self-organization

Updates become part of query processing

When an update arrives, it is not applied

For each cracker column there is a pending insertions column and a pending deletions column

Pending updates are applied only when a query needs the specific values

Page 51: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Updates aware select

We extended the cracker select operator to apply the needed updates before cracking

The select operator:1. Search the pending insertions column2. Search the pending deletions column3. If Steps 1 or 2 find tuples run an update algorithm4. Search the cracker index5. Physically reorganize the cracker column6. Update the cracker index7. Return a slice of the cracker column

Page 52: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Merging

7

2

10

29

25

31

57

42

53

Start position: 7values: >35

Start position: 4values: >12

Start position: 1values: >1

Insert a new tuple with value 9

The new tuple belongs to the blue piece 9

Page 53: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Merging

7

2

10

29

25

31

57

42

53

Start position: 8values: >35

Start position: 5values: >12

Start position: 1values: >1

Insert a new tuple with value 9

The new tuple belongs to the blue piece

9

Pieces in the cracker column are ordered

Tuples inside a piece are not ordered

Shifting is not a viable solution

Page 54: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Merging by Hopping

7

2

10

29

25

31

42

53 Start position: 8values: >35

Start position: 4values: >12

Start position: 1values: >1

57

9Insert a new tuple with value 9

We need to make enough room to fit the new tuples

Page 55: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

Merge Gradually

A query merges only the qualifying values, i.e., only the values that it needs for a correct and complete result

Average cost increases significantly

We avoid the large peaks but...

Merge CompletelyMerge Gradually

Page 56: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

The Ripple

Touch only the pieces that are relevant for the current query

Page 57: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

The Ripple

7

2

10

29

25

31

57

42

53

Start position: 7values: >35

Start position: 4values: >22

Start position: 1values: >1

Touch only the pieces that are relevant for the current query

Page 58: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

The Ripple

7

2

10

29

25

31

57

42

53

Start position: 7values: >35

Start position: 4values: >22

Start position: 1values: >1

Select 7<= A< 15Touch only the pieces that are relevant for the current query

Page 59: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

The Ripple

7

2

10

29

25

31

57

42

53

Start position: 7values: >35

Start position: 4values: >22

Start position: 1values: >1

Select 7<= A< 15

5

9

16

35

Pending insertions

Touch only the pieces that are relevant for the current query

Page 60: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

The Ripple

7

2

10

29

25

31

57

42

53

Start position: 7values: >35

Start position: 4values: >22

Start position: 1values: >1 5

9

16

35

Pending insertions

Touch only the pieces that are relevant for the current querySelect 7<= A< 15

Page 61: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

The Ripple

7

2

10

29

25

31

57

42

53

Start position: 7values: >35

Start position: 4values: >22

Start position: 1values: >1 5

9

16

35

Pending insertions

Touch only the pieces that are relevant for the current querySelect 7<= A< 15

Page 62: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

The Ripple

7

2

10

29

25

31

57

42

53

Start position: 7values: >35

Start position: 4values: >22

Start position: 1values: >1 5

9

16

35

Pending insertions

Touch only the pieces that are relevant for the current querySelect 7<= A< 15

Page 63: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

The Ripple

7

2

10

29

25

31

57

42

53

Start position: 7values: >35

Start position: 4values: >22

Start position: 1values: >1 5

9

16

35

Pending insertions

Touch only the pieces that are relevant for the current query

Avoid shifting down non interesting pieces

Select 7<= A< 15

Page 64: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

The Ripple

7

2

10

29

25

31

57

42

53

Start position: 7values: >35

Start position: 4values: >22

Start position: 1values: >1 5

9

16

35

Pending insertions

Touch only the pieces that are relevant for the current query

Avoid shifting down non interesting pieces

Select 7<= A< 15

Page 65: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

The Ripple

7

2

1029

25

31

57

42

53

Start position: 7values: >35

Start position: 4values: >22

Start position: 1values: >1 5

9

16

35

Pending insertions

Touch only the pieces that are relevant for the current query

Immediately make room for the new tuples

Avoid shifting down non interesting pieces

Select 7<= A< 15

Page 66: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

The Ripple

7

2

1029

25

31

57

42

53

Start position: 7values: >35

Start position: 4values: >22

Start position: 1values: >1 5

916

35

Pending insertions

Touch only the pieces that are relevant for the current query

Immediately make room for the new tuples

Avoid shifting down non interesting pieces

Select 7<= A< 15

Page 67: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

The Ripple

7

2

1029

25

31

57

42

53

Start position: 7values: >35

Start position: 4values: >22

Start position: 1values: >1 5

916

35

Pending insertions

Touch only the pieces that are relevant for the current query

Immediately make room for the new tuples

Avoid shifting down non interesting pieces

Select 7<= A< 15

Page 68: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

The Ripple

7

2

10

25

31

57

42

53

Start position: 7values: >35

Start position: 4values: >22

Start position: 1values: >1 5

916

35

Pending insertions

29

Touch only the pieces that are relevant for the current query

Immediately make room for the new tuples

Avoid shifting down non interesting pieces

Select 7<= A< 15

Page 69: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

The Ripple

7

2

10

25

31

57

42

53

Start position: 7values: >35

Start position: 5values: >22

Start position: 1values: >1 5

916

35

Pending insertions

29

Touch only the pieces that are relevant for the current query

Immediately make room for the new tuples

Avoid shifting down non interesting pieces

Select 7<= A< 15

Page 70: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

The Ripple

7

2

10

25

31

57

42

53

Start position: 7values: >35

Start position: 5values: >22

Start position: 1values: >1 5

916

35

Pending insertions

29

Touch only the pieces that are relevant for the current query

Immediately make room for the new tuples

Avoid shifting down non interesting pieces

Select 7<= A< 15

Page 71: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

The Ripple

Maintain high performance through the whole query sequence in a self-organizing way

Page 72: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

M.Kersten 2008

The Ripple

Maintain high performance through the whole query sequence in a self-organizing way

Merge Gradually Merge Completely

Merge Ripple

Page 73: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

Recycling intermediates

M.Kersten 2008 73

Page 74: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

30/06/2009 SIGMOD'09 Providence, RI

An Architecture for Recycling Intermediates M. Ivanova, M. L.

Kersten, N. Nes, R. Goncalves

74/20

MonetDB Background

• Operator-at-a-time execution paradigm• Canonical implementation of a column-store

• Reduced dimensionality• Finer granularity• Simplified overlap analysis

• Recycler extension of MonetDB engine

Page 75: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

30/06/2009 SIGMOD'09 Providence, RI

An Architecture for Recycling Intermediates M. Ivanova, M. L.

Kersten, N. Nes, R. Goncalves

75/20

Run-time Support

Recycler Optimizer

MonetDB Architecture

SQL

MonetDB Server

Tactical Optimizer

MonetDB Kernel

XQuery

MAL

MAL

Recycle Pool

function user.s1_2(A0:date, ...):void; X5 := sql.bind("sys","lineitem",...); X10 := algebra.select(X5,A0); X12 := sql.bindIdx("sys","lineitem",...); X15 := algebra.join(X10,X12); X25 := mtime.addmonths(A1,A2); ...

function user.s1_2(A0:date, ...):void; X5 := sql.bind("sys","lineitem",...); X10 := algebra.select(X5,A0); X12 := sql.bindIdx("sys","lineitem",...); X15 := algebra.join(X10,X12); X25 := mtime.addmonths(A1,A2); ...

Admission & Eviction

Page 76: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

30/06/2009 SIGMOD'09 Providence, RI

An Architecture for Recycling Intermediates M. Ivanova, M. L.

Kersten, N. Nes, R. Goncalves

76/20

Instruction Matching

Run time comparison of

• instruction types • argument values

Name Value Data type Size

X1 10 :bat[:oid,:date]

T1 “sys” :str

T2 “orders” :str

X1 := sql.bind("sys","orders","o_orderdate",0);…

Y3 := sql.bind("sys","orders","o_orderdate",0);

Exact matching

Page 77: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

30/06/2009 SIGMOD'09 Providence, RI

An Architecture for Recycling Intermediates M. Ivanova, M. L.

Kersten, N. Nes, R. Goncalves

77/20

Instruction Subsumption

Name Value Data type Size

X1 10 :bat[:oid,:int] 2000

X3 130 :bat[:oid,:int] 700

X5 150 :bat[:oid,:int] 350

X3 := algebra.select(X1,10,80);…

Y3 := algebra.select(X1,20,45);

X5 := algebra.select(X1,20,60);X5

Page 78: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

30/06/2009 SIGMOD'09 Providence, RI

An Architecture for Recycling Intermediates M. Ivanova, M. L.

Kersten, N. Nes, R. Goncalves

78/20

Recycle Pool: a Cache with Lineage

algebra.join

sql.bind(“C1“)

algebra.select

sql.bind(“C2“)

sql.bind(“C1“)X1 :=

algebra.select(X1)X2 :=

sql.bind(“C2“)

X3 :=

algebra.join(X2,X3)

X4 :=

Q1

Page 79: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

30/06/2009 SIGMOD'09 Providence, RI

An Architecture for Recycling Intermediates M. Ivanova, M. L.

Kersten, N. Nes, R. Goncalves

79/20

Recycle Pool: a Cache with Lineage

algebra.join

sql.bind(“C1“)

algebra.select

sql.bind(“C2“)

X1 := sql.bind(“C1“)

X2 := algebra.select(X1)

X3 := sql.bind(“C2“)

X4 := algebra.join(X2,X3)

algebra.join

sql.bind(“C3“)

X1

X2

X3

X4

Q2

Page 80: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

30/06/2009 SIGMOD'09 Providence, RI

An Architecture for Recycling Intermediates M. Ivanova, M. L.

Kersten, N. Nes, R. Goncalves

80/20

Mismatching

algebra.join

sql.bind(“C1“)

algebra.select

sql.bind(“C2“)

X1 := sql.bind(“C1“)

X2 := algebra.select(X1)

X3 := sql.bind(“C2“)

X4 := algebra.join(X2,X3)

algebra.join

sql.bind(“C3“)

Y1

Y2

Y3

Y4

Y3 := sql.bind(“C2“)

Y2 := algebra.select(Y1)

Y1 := sql.bind(“C1“)

Y4 := algebra.join(Y2,Y3)

!=X2

!=X3

Q2

Page 81: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

30/06/2009 SIGMOD'09 Providence, RI

An Architecture for Recycling Intermediates M. Ivanova, M. L.

Kersten, N. Nes, R. Goncalves

81/20

Admission Policies

Decide about storing the results

• KEEPALL• all instructions advised by the optimizer

• CREDIT • instructions supplied with credits• storage ‘paid’ with 1 credit• reuse returns credits• lack of reuse limits admission and resource claims

Page 82: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

30/06/2009 SIGMOD'09 Providence, RI

An Architecture for Recycling Intermediates M. Ivanova, M. L.

Kersten, N. Nes, R. Goncalves

82/20

Cache Policies

• Decide about eviction of intermediates• Filter ‘top’ instructions without dependents• Pick instructions with smallest utility

• LRU : time of computation or last reuse• BENEFIT : estimated contribution to performance: CPU

and I/O costs, recycling

• Triggered by resource limitations (memory or entries)

Page 83: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

30/06/2009 SIGMOD'09 Providence, RI

An Architecture for Recycling Intermediates M. Ivanova, M. L.

Kersten, N. Nes, R. Goncalves

83/20

TPC-H Evaluation

• SF1• Baseline performance• Impact of design choices

• Admission policies• Cache policies

Page 84: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

30/06/2009 SIGMOD'09 Providence, RI

An Architecture for Recycling Intermediates M. Ivanova, M. L. Kersten, N. Nes, R. Goncalves 84/20

CREDIT Admission Impact

Reused memory Reused entries

Hit ratio to KeepAll

Page 85: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

30/06/2009 SIGMOD'09 Providence, RI

An Architecture for Recycling Intermediates M. Ivanova, M. L.

Kersten, N. Nes, R. Goncalves

85/20

Cache Policies Evaluation

200 TPC-H queries

RP Total Reuse

Memory 4GB 42.7%

Entries 5219 28%

Page 86: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

30/06/2009 SIGMOD'09 Providence, RI

An Architecture for Recycling Intermediates M. Ivanova, M. L.

Kersten, N. Nes, R. Goncalves

86/20

SkyServer Evaluation

• 100 GB subset of DR4

• 100-query batch from January 2008 log

• 1.5GB intermediates, 99% reuse

• Join intermediates major contributor to savings

Page 87: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

30/06/2009 SIGMOD'09 Providence, RI

An Architecture for Recycling Intermediates M. Ivanova, M. L.

Kersten, N. Nes, R. Goncalves

87/20

Summary

• Database architecture augmented with recycling intermediates

• Significant performance benefits in SkyServer and TPC-H

• Self-organizing technique• Extension to MonetDB transforming

materialization overhead into benefit

Page 88: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

30/06/2009 SIGMOD'09 Providence, RI

An Architecture for Recycling Intermediates M. Ivanova, M. L.

Kersten, N. Nes, R. Goncalves

88/20

Future Work

• Refining and developing admission and cache policies

• Opportunities by query class recognition• Automatic switch to suitable policies

• Application to pipelined architectures

Page 89: M.Kersten 2008 1 MonetDB, Cracking and recycling Martin Kersten CWI Amsterdam

30/06/2009 SIGMOD'09 Providence, RI

An Architecture for Recycling Intermediates M. Ivanova, M. L.

Kersten, N. Nes, R. Goncalves

89/20

Recycling

Is Green