Column Store Tutorial VLDB09
Column Store Tutorial VLDB09
VLDB
Column-Oriented 2009
Tutorial
Database Systems
Part 1: Stavros Harizopoulos (HP Labs)
Part 2: Daniel Abadi (Yale)
Part 3: Peter Boncz (CWI)
What is a column-store?
row-store column-store
Date Store Product Customer Price
Date Store Product Customer Price
Outline
l Part 1: Basic concepts — Stavros
l Introduction to key features
l From DSM to column-stores and performance tradeoffs
l Column-store architecture overview
l Will rows and columns ever converge?
QUERY 2
SELECT account.account_number,
sum (usage.toll_airtime),
sum (usage.toll_price) Column-store Row-store
FROM usage, toll, source, account
WHERE usage.toll_id = toll.toll_id
Query 1 2.06 300
AND usage.source_id = source.source_id Query 2 2.20 300
AND usage.account_id = account.account_id
AND toll.type_ind in (‘AE’. ‘AA’)
Query 3 0.09 300
AND usage.toll_price > 0 Query 4 5.24 300
AND source.type != ‘CIBER’
AND toll.rating_method = ‘IS’
Query 5 2.88 300
AND usage.invoice_date = 20051013
GROUP BY account.account_number
Why? Three main factors (next slides)
VLDB 2009 Tutorial Column-Oriented Database Systems 5
Re-use permitted when acknowledging the original © Stavros Harizopoulos, Daniel Abadi, Peter Boncz (2009)
l Why?
l Rows contain values from different domains
=> more entropy, difficult to dense-pack
l Columns exhibit significantly less entropy
l Examples: Male, Female, Female, Female, Male
1998, 1998, 1999, 1999, 1999, 2000
original
Time (sec)
C-store
enable
late
column-oriented enable materialization
join algorithm compression &
operate on compressed
avoid decompression
l Execution engine Part 2
late materialization
Outline
l Part 1: Basic concepts — Stavros
l Introduction to key features
l From DSM to column-stores and performance tradeoffs
l Column-store architecture overview
l Will rows and columns ever converge?
“A decomposition storage
The original DSM paper model” Copeland and
Khoshafian. SIGMOD 1985.
l Proposed as an alternative to NSM
l 2 indexes: clustered on ID, non-clustered on value
l Speeds up queries projecting few columns
l Requires more storage value
ID 0100 0962 1000 ..
1 2 3 4 ..
l Fractured mirrors
l Smart mirroring with both NSM/DSM copies
“A Case For Fractured
Mirrors.” Ramamurthy,
DeWitt, Su, VLDB 2002.
l C-store paper:
l First comprehensive design description of a column-store
l MonetDB/X100
l “proper” disk-based column store
l Explosion of new products
VLDB 2009 Tutorial Column-Oriented Database Systems 18
Re-use permitted when acknowledging the original © Stavros Harizopoulos, Daniel Abadi, Peter Boncz (2009)
4 a4 a1 a2 a3 a4 a5
1 4
5 a5
Similar: storage density “Efficient columnar
comparable storage in B-trees” Graefe.
to column stores Sigmod Record 03/2007.
VLDB 2009 Tutorial Column-Oriented Database Systems 20
Re-use permitted when acknowledging the original © Stavros Harizopoulos, Daniel Abadi, Peter Boncz (2009)
time
row
regular DSM
column?
columns projected:
1 2 3 4 5
optimized
l Chunk-based tuple merging DSM
l Read in segments of M pages
l Merge segments in memory
l Becomes CPU-bound after 5 pages
Joe 45
… …
Joe 45
… … SELECT name, age
WHERE age > 40
apply S
predicate(s)
S #POS 45
Joe #POS …
Direct I/O Sue
…
prefetch ~100ms apply
1 Joe 45 worth of data predicate #1 S
2 Sue 37
…… …
45
37
…
VLDB 2009 Tutorial Column-Oriented Database Systems 22
Re-use permitted when acknowledging the original © Stavros Harizopoulos, Daniel Abadi, Peter Boncz (2009)
Scan performance
l Large prefetch hides disk seeks in columns
l Column-CPU efficiency with lower selectivity
l Row-CPU suffers from memory stalls not shown,
l Memory stalls disappear in narrow tuples details in the paper
Time (s)
15
10
5
wide attributes:
same as before 0
1 2 3 4 5 6 7 8 9 10
Columns Returned
72
(cpdb) 36
+++
18
_ = + ++
9
8 12 16 20 24 28 32 36
tuple width
l Rows favored by narrow tuples and low cpdb
l Disk-bound workloads have higher cpdb
VLDB 2009 Tutorial Column-Oriented Database Systems 25
Re-use permitted when acknowledging the original © Stavros Harizopoulos, Daniel Abadi, Peter Boncz (2009)
30
Column 8
20 Column 16
Column 48 (x 128KB)
10
Row (any prefetch size)
0
4 8 12 16 20 24 28 32
selected bytes per tuple
time (sec)
30 Row, 48 30
20 20
10 10 Column, 8
Row, 8
0 0
4 12 20 28 4 12 20 28
selected bytes per tuple
mini-pages with no
qualified attributes are
not accessed
from 7x slower
..to 2x slower
..to same
and 3x faster!
Outline
l Part 1: Basic concepts — Stavros
l Introduction to key features
l From DSM to column-stores and performance tradeoffs
l Column-store architecture overview
l Will rows and columns ever converge?
Architecture of a column-store
storage layout
l read-optimized: dense-packed, compressed
l organize in extends, batch updates
l multiple sort orders
l sparse indexes engine
l block-tuple operators
l Compress columns
l No alignment
l Big disk blocks
l Only materialized views (perhaps many)
l Focus on Sorting not indexing
l Data ordered on anything, not just time
l Automatic physical DBMS design
l Optimize for grid computing
l Innovative redundancy
l Xacts – but no need for Mohan
l Column optimizer and executor
§Memory based
A B C
§Unsorted / Uncompressed
§Segmented
§Low latency / Small quick (A B C | A)
inserts
VLDB 2009 Tutorial Column-Oriented Database Systems 36
Re-use permitted when acknowledging the original © Stavros Harizopoulos, Daniel Abadi, Peter Boncz (2009)
Outline
l Part 1: Basic concepts — Stavros
l Introduction to key features
l From DSM to column-stores and performance tradeoffs
l Column-store architecture overview
l Will rows and columns ever converge?
…
VLDB 2009 Tutorial Column-Oriented Database Systems 41
Re-use permitted when acknowledging the original © Stavros Harizopoulos, Daniel Abadi, Peter Boncz (2009)
Experiments
l Star Schema Benchmark (SSBM) Adjoined Dimension Column Index (ADC Index)
to Improve Star Schema Query Performance”.
O’Neil et. al. ICDE 2008.
100.0
50.0
0.0
Vertically Partitioned Row-Store With All
Normal Row-Store
Row-Store Indexes
Average 25.7 79.9 221.2
1
l Do not work well as full-columns
2
l TupleID overhead significant
3
l Excessive joins
Queries touch 3-4 foreign keys in fact table,
1-2 numeric columns
“Column-Stores vs. Row-Stores: Complete fact table takes up ~4 GB
How Different Are They Really?” (compressed)
Abadi, Madden, and Hachem. Vertically partitioned tables take up 0.7-1.1
SIGMOD 2008. GB (compressed)
So….
l All indexes approach is a poor way to simulate a column-store
l Problems with vertical partitioning are NOT fundamental
l Store tuple header in a separate partition
l Allow virtual TIDs
l Combine clustered indexes, vertical partitioning
l So can row-stores simulate column-stores?
l Might be possible, BUT:
l Need better support for vertical partitioning at the storage layer
l Need support for column-specific optimizations at the executer level
l Full integration: buffer pool, transaction manager, ..
End of Part 1
l Basic concepts — Stavros
l Introduction to key features
l From DSM to column-stores and performance tradeoffs
l Column-store architecture overview
l Will rows and columns ever converge?