It’s been a bit more than 2 years since SAP introduced the “In Memory” marketing push, starting with Hasso Plattner’s speech at Sapphire … or was it TechEd … my memory fails me 😉
It has been two years and I have yet to see a good understanding emerge in the SAP community about what SAP actually means when it talks about “In Memory”. I put the phrase “In Memory” into quotes, because I want to emphasize that it has a meaning entirely different from the standard English meaning of the two words “in” and “memory”. This is a classic case, best summed up by a quote from one of the favorite movies of my childhood:
Vizzini: HE DIDN’T FALL? INCONCEIVABLE.
Inigo Montoya: You keep using that word. I do not think it means what you think it means.
http://www.imdb.com/title/tt0093779/quotes?qt0482717The only reasonably specific explanation of the “In Memory” term that I have seen from SAP is in this presentation by Thomas Zurek – on page 11.
If you want a coherent, official stance from SAP on “In Memory” and the impact of HANA on BW, I highly recommend reading and understanding this presentation. I think I can add a little more detail and ask some important questions, so here is my take:http://www.imdb.com/title/tt0093779/quotes?qt0482717
Fact (I think…)
SAP is talking about at least 4 separate but complementary technologies when it says “In Memory”:
1. Cache data in RAM
This is the easy one, and is what most people assume the phrase means. But as we will see below, this is only part of the story.
By itself, caching data in RAM is no big deal. Yes, with cheaper RAM and 64-bit servers, we can cache more data in RAM than ever before, but this doesn’t give us persistence, nor does working on data in RAM guarantee a large speedup in processing for all data-structures. Often, more RAM is a very expensive way to achieve a very small performance gain.
2. Column-based storage
Columnar storage has been around for a long time, but it was introduced to the SAP eco-system in the BWA (formerly BIA, now BAE under HANA – gotta respect the acronyms) product under the guise of “In Memory” technology. The introduction of a column-based data model for use in analytic applications was probably the single biggest performance win for BWA and followed in the footsteps of pioneering analytical databases like Sybase IQ, but it was largely ignored.
Interestingly, Sybase IQ is a disk-based database, and yet displays many of the same performance characteristics for analytical queries that BWA boasts. Further evidence that not all of BWA’s magic is enabled by storing data in RAM.
So how do we fit all of that data in to RAM? Well, in the case of BWA the answer is that we don’t – it stores a lot of data on disk and then caches as much as possible in RAM. But we can fit a lot more data into RAM if it is compressed. BWA, and HANA, implement compression algorithms to shrink data volume by up to 90% (or so we are told).
Compression and columnar storage go hand-in-hand for two reasons:
- Column-based storage usually sorts columns by value, usually at the byte-code level. This results in similar values being close to each other, which happens to be a data layout that results in highly efficient compression using standard compression algorithms that make use of similarities in adjacent data. Wikipedia has the scoop here: http://en.wikipedia.org/wiki/Column-oriented_DBMS#Compression
- When queries are executed on a column-oriented store it is often possible to execute the query directly on the compressed data. That’s right – for some types of queries on columnar-databases you don’t need to decompress the data in order to retrieve the correct records. This is because knowledge of the compression scheme can be built into the query engine, so query values can be converted into their compressed equivalents. If you choose a compression scheme that maintains ordering of your keys (like Run Length Encoding), you can even do range queries on compressed data. This paper is a good discussion of some of the advantages of executing queries on compressed data: http://db.csail.mit.edu/projects/cstore/abadisigmod06.pdf
4. Move processing to the data
Lastly, the BWA and HANA systems make heavy use of the technique of moving processing closer to the data, rather than moving data to the processing. In essence, the idea is that it is very costly to move large volumes of data across a network from a database server to an application server. Instead, it is often more efficient to have the database server execute as much processing as possible and then send a smaller result set back to the application server for further processing. This processing trade-off has been known for a long time, but the move-processing-to-the-data approach was popularized relatively recently as a core principle of the Map-Reduce algorithm pioneered by Google: http://labs.google.com/papers/mapreduce.html
This approach is especially useful when an analytical database server (which tends to have high data volumes) implements columnar-storage and parallelization with compression and heavy RAM-caching, so that it is capable of executing processing without becoming a bottle-neck.
There are also a few technologies that I suspect SAP has rolled into HANA, but since they don’t share the detailed technical architecture of the product, I don’t know for sure.
1. Parallel query evaluation
Parallel query execution (sometimes referred to as MPP, or massively-parallel-processing, which is a more generic term) involves breaking up, or sometimes duplicating, a dataset across more than one hardware node and then implementing a query execution engine that is highly aware of the data layout and is capable of splitting queries up across hardware. Often this results in more processing (because it turns one query into many, with an accompanying duplication of effort) but faster query response times (because each of the smaller sub-queries executes faster and in parallel). MPP is another concept that has been around for a long time but was popularized recently by the Map-Reduce paradigm. Several distributed DBMSes implement parallel query execution, including Vertica, Teradata, and hBase
Since HANA is billed as ANSI SQL-compliant and ACID-compliant, it clearly delivers full write-persistence. What is not clear is what method is used to achieve fast and persistent writes along with a column-based data model. Does it use a write-ahead-log with recovery? Maybe a method involving a log combined with point-in-time snapshots? Some other method? Each approach has different trade-offs with regards to memory consumption and the ability to maintain performance under a sustained onslaught of write operations.