SAPBR Technologies home

SAP in Brazil, explained

In-Memory Data Management – Part I

This series explains how a column-oriented, dictionary-encoded, in-memory database works and why it matters for enterprise computing.

It draws on Hasso Plattner’s book A Course in In-Memory Data Management: The Inner Mechanics of In-Memory Databases, the online courses by Hasso Plattner and Dr.-Ing. Jürgen Müller, SAP Help and other sources, plus my own take. The book’s learning map gives the structure:

I. The future of enterprise computing (this post)

  1. New requirements for enterprise computing
  2. Enterprise application characteristics
  3. Changes in hardware
  4. Blueprint of SanssouciDB

II. Foundations of database storage techniques: dictionary encoding and compression; data layout (row, column, hybrid); partitioning

III. In-memory database operators: insert, update, delete; scan performance; tuple reconstruction; SELECT; materialization strategies; parallel data processing; indexes; JOIN; aggregate functions; parallel SELECT; workload management; parallel join; parallel aggregate functions

IV. Advanced database storage techniques: differential buffer; insert-only time travel; merge; logging and recovery; on-the-fly reorganization

V. Foundations for a new era of enterprise applications: application development; implications; dunning; views; business objects; bypass solution

I. The future of enterprise computing

1. New requirements for enterprise computing

We expect enterprise systems to be as fast and simple as Google search. Two examples of applications reading huge volumes of sensor data:

A European pharmaceutical supply chain

  • 15 billion packages tracked, 34 billion read events a year
  • Read events stored in distributed repositories
  • References to them kept in a central discovery service
Dublin pharmaceutical warehouse
United Drug Supply Chain Service is Ireland’s leading pharmaceutical distributor, part of UDG Healthcare.

Formula 1 car sensors

  • 300 to 600 sensors per car
  • Several readings per second, per sensor, per car
  • About 2 hours per Grand Prix, 20 races a year
  • 43 to 86 billion events per car per season; 800 billion to 1.728 trillion for the whole grid
Formula 1 car
About 80,000 components go into an F1 car; at 99.9% accuracy, 80 would be wrong.

Can a team read all that data fast enough to predict the race or change strategy mid-race? See how McLaren does it: ‘The biggest science project on the planet’ was on a racetrack on Sunday.

Two more examples, mixing structured and unstructured data (file formats, handwritten notes):

Boeing aircraft maintenance

  • Technicians write a report after each repair
  • Part numbers replaced or repaired are indexed
  • Analytics show which parts in other aircraft may fail
Boeing factory
Boeing, Everett, Washington

Medical diagnosis in a large connected health system

  • Doctors write a report after each diagnosis
  • Diagnoses, symptoms, drugs and reactions are indexed
  • Similar cases suggest the best treatment
Medical diagnosis
Deep neural networks can train diagnostic systems that keep improving from pooled data.

In all four cases the data holds valuable knowledge, whether for profit and cost (pharma, F1) or for saving lives (aircraft, medicine). Storing and analyzing it used to be limited by hardware and database design. Those limits are gone, and AI, machine learning, big data and IoT let companies rethink how they work.

2. Enterprise application characteristics

How enterprise applications use the database

One database serves very different workloads:

  • Transactional data entry: orders, invoices and other data coming in.
  • Real-time analytics on structured data: sales to date, next-quarter forecasts, year-over-year profit.
  • Event processing and streaming: sensor readings like the examples above.
  • Text analytics on unstructured data: sentiment on Twitter, Facebook and other social media. If you miss a discussion for a week or a month, your reputation is already hurt.
Enterprise database workloads

OLTP vs. OLAP

A database does two kinds of work. OLTP (online transaction processing) covers entering sales orders and billing documents, posting receivables, and displaying a single document or master record. OLAP (online analytical processing) analyzes that data: reporting, sales forecasts, payment reminders, cross-selling (for example, spotting an upsell from a customer’s social media interests).

OLAP vs. OLTP

Systems were built to handle them separately because analytical queries run longer and would slow down core processes like manufacturing and sales. Companies extracted data from OLTP into a separate system optimized for OLAP.

The assumption was that OLTP is write-heavy and OLAP is read-only. Research across many companies shows otherwise:

  • Lookups in OLTP are only about 10% higher than in OLAP.
  • Inserts are slightly higher in OLTP, but OLAP also inserts to stay in sync.
  • Updates are rarer than believed: about 12% of OLTP rows are ever updated, so 88% never are.
  • 83% of OLTP workload is reads (you read an invoice before sending it); only 17% is writes.
OLTP and OLAP workload

Since both are read-heavy, why not use OLAP’s read optimizations in OLTP too? That’s where column orientation comes in, made possible by modern hardware: one source of truth for real-time analytics, calculated on the fly, without stored aggregates.

The remaining difference: OLTP runs many queries returning a few rows; OLAP aggregates a few columns over many rows. Keeping the two in sync takes a large, slow and complex ETL process.

The cost of separating OLAP from OLTP

Separation optimizes each workload, but:

  • OLAP never has current data. Refreshes take minutes to hours, so decisions rely on old data. Twitter alone sees over 350,000 tweets a minute; customer mood can change in minutes.
  • OLAP needs materialized aggregates for acceptable performance, which limits reporting flexibility.
  • The schemas differ, so applications using both need complex ETL.
  • Usually only a subset of transactional data is exported, report by report, which creates redundancy between reports.

What can change

Research on company systems shows that as tables get wider, many fields go unused. In tables with hundreds of columns, more than 50% are never used; most of the rest have few distinct values or are full of NULLs and defaults. That makes compression very effective.

Across financial accounting header documents in consumer goods, logistics, banking, high-tech and discrete manufacturing, the tables had 99 fields. Only a few columns had many distinct values (usually the keys), a few had 10% to 30%, and many were never used. In inventory management and financial accounting, most columns have only 1 to 32 distinct values.

Number of distinct values per column

Among the 144 most-used tables in an ERP system, 26 have 1 to 9 columns, while others have more than 120, and some 200 to almost 400. How do you make those tables efficient?

Number of columns per table

3. Changes in hardware

IBM RAMAC 305
In 1956, IBM introduced the first hard disk, the RAMAC 305: fifty 24-inch platters, about one ton, 5 MB of storage, leased for $3,200 a month in 1957 dollars (about $160,000 to buy).

Until 2002, hard disks used the same basic technology as the RAMAC.

2017: 1 TB SD and microSD cards

Hardware enables a rethink

Hardware changes

Memory hierarchy

This database uses main memory as primary storage. Flash and spinning disks are only for recovery. It’s also optimized for CPU caches (L1, L2, L3), where computing happens.

Memory hierarchy

Memory used to be expensive, so servers had little of it. Data flowed from disk to CPU through a narrow gateway and the CPU sat idle waiting. As prices dropped, companies got terabytes of memory, and multi-core processors made it possible to run complex work such as predictive analysis in parallel, in real time. Only memory can feed data to the CPU fast enough.

Fabric-based computing

Porting ERP applications written over 20 years to the new hardware would help, but classic databases and applications were designed around old hardware limits and couldn’t use its full power. So SAP, the ERP market leader, decided to reinvent the database, and started designing HANA.

Latency numbers

Latency numbers

Reading from L1 cache takes 0.5 ns. Reading from main memory through the cache hierarchy takes 100 ns: fast, but 200× slower than L1. The further data sits from the core, the longer it takes. A disk seek is 100,000× slower than main memory and 20 million× slower than L1. If you can, keep all data in memory.

What’s a nanosecond? One billionth of a second (10⁻⁹ s). A nanosecond is to a second what a second is to 31.71 years. It’s the speed modern applications need.

Latency numbers at human scale

Disk access has been pushed to the physical limits of spinning platters. Modern CPUs use layered caches to manage on-board memory efficiently. SAP worked with CPU makers on co-development to learn how data moves from memory to core and use processors to the fullest.

Main memory is volatile, so disks are still needed for logs and backups, though even that may move to SSDs.

4. Blueprint of SanssouciDB

SanssouciDB is a research database that serves ERP transactions and analytics from the same data store, in memory. It has a column-store engine for fast analytics and transactions on sparse tables, plus an engine for combined columns: column groups used to materialize result sets and intermediates, and for transactions that touch many attributes at once.

Main memory loses data on shutdown, so the in-memory database still uses logging and recovery on disk. Since memory, not disk, is now the bottleneck (100× slower than L1), algorithms must be cache-conscious to move data from memory to the CPU as fast as possible.

SanssouciDB architecture

The main store holds column-organized data, and a differential buffer is merged into it periodically. Indexes are optional, since the column store without aggregates is effectively fully indexed. Memory snapshots go to disk periodically, and logging guarantees a complete restore after a shutdown.

That’s chapter I. Part II covers chapter II, foundations of database storage.

Comments

2 responses to “In-Memory Data Management – Part I”

  1. In-Memory Data Management – Part II – SAP BRAZIL & S/4HANA Avatar

    […] This post is a sequence of In-Memory Data Management – Part I. […]

    Like

  2. Alex Avatar
    Alex

    Nice blog right here! Also your site loads up fast! What host are you using? Can I get your associate link to your host? I want my site loaded up as quickly as yours lol

    Like

Leave a Reply