Skip to Main Content
  • Questions
  • difference b/w row database and column database, how the data will compressed in database

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, ramesh.

Asked: July 12, 2016 - 8:55 am UTC

Last updated: July 12, 2016 - 10:07 am UTC

Version: n/a

Viewed 1000+ times

You Asked

Hi Tom,

I have to questions i.e;

1.what is difference b/w row database and column database, how can we create indexes on column database?

2.how the data will be compressed in database(on what basis data will be compressed in database)?


and Chris said...

1. Row format vs. columnar format relates to how the database stores data.

Oracle Database is a row format database. This means it stores all the columns for a given row in the same location (a block in Oracle).

This means you can fetch all the data for a given row in a single IO operation. Though a row could span multiple blocks for various reasons. For example, it's too large to fit in a single block.

Columnar format stores values for a given column in the same location. The In-Memory option uses this format. It stores the values in In-Memory compression units or IMCUs.

So if you want to fetch all the columns for a given row you need an IO operation per column. But if you're only returning one column for several rows, this may only be a couple of IO operations.

You can read more about this in the In-Memory whitepaper:

http://www.oracle.com/technetwork/database/in-memory/overview/twp-oracle-database-in-memory-2245633.html

Thus fetching few rows and many columns is typically faster with row format data.
Fetching many rows and few columns is typically faster with columnar format data. A more detailed discussion of which queries benefit from which format is at:

http://www.oracle.com/technetwork/database/in-memory/overview/twp-dbim-usage-2441076.html

There's no need to create indexes on columnar format data (not in Oracle at least). One of the benefits of using In-Memory is it enables you to remove indexes!

2. By default Oracle does not compress row data. You have to enable it explicitly. There are different levels of compression available. Basic compression is part of EE. OLTP compression is part of the Advanced Compression option:

http://www.oracle.com/technetwork/database/focus-areas/storage/advanced-compression-whitepaper-130502.pdf

In-Memory data are compressed by default. You can specify different levels of compression. See the whitepaper above for more details.

In both cases compression works by only storing repeated values once. Exactly how this works depends upon the level you've provided and whether it's row vs. column format data.

Is this answer out of date? If it is, please let us know via a Comment