# Storage Formats

| Account number | Last name | First name | Purchase (in dollars) |
| -------------- | --------- | ---------- | --------------------- |
| 1001           | Green     | Rachel     | 20.12                 |
| 1002           | Geller    | Ross       | 12.25                 |
| 1003           | Bing      | Chandler   | 45.25                 |

### Row Oriented Storage

In a row-oriented DBMS, the data would be stored as

1001,Green,Rachel,20.12;1002,Geller,Ross,12.25;1003,Bing,Chandler,45.25

Best suited for OLTP - Transaction data.

### Columnar Oriented Storage

1001,1002,1003;Green,Geller,Bing;Rachel,Ross,Chandler;20.12,12.25,45.25

Best suited for OLAP - Analytical data.

1. **Compression**: Since the data in a column tends to be of the same type (e.g., all integers, all strings), and often similar values, it can be compressed much more effectively than row-based data.
2. **Query Performance**: Queries that only access a subset of columns can read just the data they need, reducing disk I/O and significantly speeding up query execution.
3. **Analytic Processing**: Columnar storage is well-suited for analytical queries and data warehousing, which often involve complex calculations over large amounts of data. Since these queries often only affect a subset of the columns in a table, columnar storage can lead to significant performance improvements.

<figure><img src="https://1471795080-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrtXPLjVTxuTGIysjCx89%2Fuploads%2FDC3zFp3QLIRadqvFhfnP%2Fimage.png?alt=media&#x26;token=6ebfef3a-d37d-4cc0-9b93-86f29d646145" alt=""><figcaption><p><a href="https://mariadb.com/resources/blog/why-is-columnstore-important/">https://mariadb.com/resources/blog/why-is-columnstore-important/</a></p></figcaption></figure>
