The SAP HANA database allows you to create your tables in Row or Column Store mode. In this blog, I will demonstrate that each method has its advantages and disadvantages and should be used for specific cases.

Thanks to two kind of tests, I will show you that the Row Store mode should be used for simple SELECT SQL queries, without aggregation and the Column Store mode should be used for complex SELECT queries, containing aggregation levels.

If you want to have more information regarding the Column Store or the In-memory technologies, don’t hesitate to assist at the next dbi services event:
https://www.dbi-services.com/newsroom/events/

Test 1: Simple SELECT query

Goal of the tests

This test will show you the difference of performance using a Row Store and a Column Store table in a simple SQL query.

Description of the test

A SELECT query will be send to the database and we will check the Server time response.

SQL Query

Using a Row Store table

The SQL is the following:

1_SQL_ROW_STORE.PNG

Using a Column Store table
The SQL is the following:

2_SQL_COLUMN_STORE.PNG

Tables

Row Store Table

You can find here information regarding the Row Store table used in the test.

Name:                 SALES_ROW
Table type:          Row Store
Row count:         10 309 873
Index:                1
Partition:            0 (SAP HANA doesn’t allow the possibility to create partition on Row Store table)

3_TABLE_ROW_STORE_1.PNG

4_TABLE_ROW_STORE_2.PNG

Column Store Table

You can find here information regarding the Column Store table used in the test.

Name:                  SALES_COLUMN
Table type:           Column Store
Row count:          10 309 873
Index:                 0 (SAP HANA automatically apply a index if it is need)
Partition:             1 RANGE partition on CUST_ID

6_TABLE_COLUMN_STORE_2.PNG

Result of the test

Using the Row Store table

8_SQL_Q1_SELECT_ROW_RESULT.PNG

Using the Column Store table

9_SQL_Q1_SELECT_COLUMN_RESULT.PNG

Test 2: Complex SELECT query

Goal of the tests

This test will show you the difference of performance using a Row Store and a Column Store table in a complex SQL query.

Description of the test

A SELECT query will be send to the database and we will check the Server time response.

SQL Query

Using a Row Store table

The SQL is the following:

10_SQL_ROW_STORE.PNG

Using a Column Store table
The SQL is the following:

11_SQL_COLUMN_STORE.PNG

Tables

Row Store Fact Table

You can find here information regarding the Row Store table used in the test.

Name:                  SALES_ROW
Table type:          Row Store
Row count:         10 309 873
Index:                   2
Partition:             0 (SAP HANA doesn’t allow the possibility to create partition on Row Store table)

Column Store Fact Table

You can find here information regarding the Column Store table used in the test.

Name:                  SALES_COLUMN
Table type:          Column Store
Row count:         10 309 873
Index:                   0 (SAP HANA automatically apply a index if it is need)
Partition:             1 RANGE partition on CUST_ID

Result of the test

Using the Row Store tables

12_SQL_Q2_SELECT_ROW_RESULT.PNG

Using the Column Store tables

13_SQL_Q2_SELECT_COLUMN_RESULT.PNG

Conclusion

Row and Column store modes in SAP HANA should be used in two different contexts:

  • Tables in Row store mode must be used in SELECT queries WITHOUT any aggregation functions
  • Tables in Column store mode are powerful when they are used to create analytical queries or view, using aggregation functions (GROUP BY, …)

The performance can be highly optimized if the tables selected in the queries have the right store mode.