Data orientation

From Wikipedia, the free encyclopedia
(Redirected from Column-oriented DBMS)
Jump to navigation Jump to search

Data orientation is the representation of tabular data in a linear memory model such as in-disk or in-memory. The two most common representations are column-oriented (columnar format) and row-oriented (row format).[1][2]

The choice of data orientation is a trade-off and an architectural decision in databases, query engines, and numerical simulations.[1] As a result of these tradeoffs, row-oriented formats are more commonly used in online transaction processing (OLTP) and column-oriented formats are more commonly used in online analytical processing (OLAP).[2]

Examples of column-oriented formats include Apache ORC,[3] Apache Parquet,[4] Apache Arrow,[5] formats used by BigQuery, Amazon Redshift and Snowflake. Predominant examples of row-oriented formats include CSV, formats used in most relational databases (Oracle, MySQL etc.), the in-memory format of Apache Spark, and Apache Avro.[6]

Description

[edit | edit source]

Tabular data is two dimensional — data is modeled as rows and columns. However, computer systems represent data in a linear memory model, both in-disk and in-memory.[7][8][9] Therefore, a table in a linear memory model requires mapping its two-dimensional scheme into a one-dimensional space. Data orientation is to the decision taken in this mapping. There are two prominent mappings: row-oriented and column-oriented.[1][2]

Row-oriented

[edit | edit source]

In a row-oriented database, also known as a rowstore, the elements of the table

column 1 column 2 column 3
item 11 item 12 item 13
item 21 item 22 item 23

are stored linearly as

item 11 item 12 item 13 item 21 item 22 item 23

I.e. each row of the table is located one after the other. In this orientation, values in the same row are close in space (e.g. similar address in an addressable space).

Examples

[edit | edit source]

Column-oriented

[edit | edit source]

In a column-oriented database, also known as a columnstore, the elements of the table

column 1 column 2 column 3
item 11 item 12 item 13
item 21 item 22 item 23

are stored linearly as

item 11 item 21 item 12 item 22 item 13 item 23

I.e. each column of the table is located one after the other. In this orientation, values on the same column are close in space (e.g. similar address in an addressable space).

Examples

[edit | edit source]

See list of column-oriented DBMSes for more examples.

Tradeoff

[edit | edit source]

Data orientation is an important architectural decision of systems handling data because it results in important tradeoffs in performance and storage.[8] Below are selected dimensions of this tradeoff.

Random access

[edit | edit source]

Row-oriented benefits from fast random access of rows. Column-oriented benefits from fast random access of columns. In both cases, this is the result of fewer page or cache misses when accessing the data.[8]

Insert

[edit | edit source]

Row-oriented benefits from fast insertion of a new row. Column-oriented benefits from fast insertion of a new column.

This dimension is an important reason why row-oriented formats are more commonly used in online transaction processing (OLTP), as it results in faster transactions in comparison to column-oriented.[2]

Conditional access

[edit | edit source]

Row-oriented benefits from fast access under a filter. Column-oriented benefits from fast access under a projection.[4][3]

Compute performance

[edit | edit source]

Column-oriented benefits from fast analytics operations. This is the result of being able to leverage SIMD instructions.[5]

Uncompressed size

[edit | edit source]

Column-oriented benefits from smaller uncompressed size. This is the result of the possibility that this orientation offers to represent certain data types with dedicated encodings.[4][3]

For example, a table of 128 rows with a Boolean column requires 128 bytes in a row-oriented format (one byte per Boolean) but 128 bits (16 bytes) in a column-oriented format (via a bitmap). Another example is the use of run-length encoding to encode a column.

Compressed size

[edit | edit source]

Column-oriented benefits from smaller compressed size. This is the result of a higher homogeneity within a column than within multiple rows.[4][3]

Conversion and interchange

[edit | edit source]

Because both orientations represent the same data, it is possible to convert a row-oriented dataset to a column-oriented dataset and vice versa at the expense of compute. In particular, advanced query engines often leverage each orientation's advantages, and convert from one orientation to the other as part of their execution. As an example, an Apache Spark query may

  1. Read data from Apache Parquet (column-oriented)
  2. Load it into the Spark internal in-memory format (row-oriented)
  3. Convert it to Apache Arrow for a specific computation (column-oriented)
  4. Write it to Apache Avro for streaming (row-oriented)

References

[edit | edit source]
  1. ^ a b c Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  2. ^ a b c d Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  3. ^ a b c d Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  4. ^ a b c d Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  5. ^ a b Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  6. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  7. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  8. ^ a b c Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  9. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  10. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).