Need some help? Ask here.
ASK A QUESTION.

Thanks for taking the time to reach out to us! We take support and feedback extremely seriously and will get back to you as soon as possible.

SUBMIT
QUESTION.


WHAT IS MEMSQL?

MemSQL is a next generation database that removes the most common bottleneck applications hit today: disk. By offering a familiar relational interface to an in-memory data tier, MemSQL empowers developers with the technology web-scale companies use to cope with massive traffic and growth. MemSQL offers orders of magnitude improvements in write and read performance and greatly simplifies application development and maintenance by offering wire-compatibility with MySQL.

NATIVE REPLICATION

MemSQL 1.8 ships with native replication that is simple to run and blazingly fast. MemSQL replication supports fully online provisioning: you do not have to lock or stop the master to start it. You will never have to worry about manually copying a database, rotating binlogs, resolving inconsistencies, or locking down writes to the master. See MemSQL Replication Tutorial for a detailed walkthrough of MemSQL replication.

MEMSQL DISTRIBUTED

MemSQL's distributed system scales incrementally across commodity hardware, so you can build the system that meets your needs in terms of both data volume and query performance. It leverages a two-tiered architecture comprised of aggregators and leaves with no single point of failure. Aggregators store cluster metadata so that they can intelligently distribute queries across relevant leaf nodes, then aggregate the results back up to the client. A leaf node is just a MemSQL single-box database.

Parser

When a query hits the system, the first component it encounters is a one-pass, linear scan parser that strips it of its numeric and string parameters. The result is a query skeleton that can be saved in the plan cache.

This parser is extremely fast: it is optimized instruction-by-instruction to impose minimal low-overhead.

The resulting query skeletons are just strings. For example, SELECT * FROM users WHERE id=5 is transformed to SELECT * FROM users WHERE id=@.

Code Generator

The code generator is responsible for converting a query skeleton into C++ code that executes the query. This component is only invoked if the query skeleton has not been encountered by the system before.

The concept is similar to Facebook Hip-Hop. Instead of executing SQL as an interpreted language, MemSQL converts the SQL parse tree directly into C++ code and compiles it into highly optimized native code.

When code generation completes, the resulting plan is loaded into the database as a shared object and registered in the plan cache.

Plan Cache

The plan cache correlates query skeletons to compiled plans. It is implemented as a lightweight, lock-free hashtable.

If a query skeleton produced by the parser has been encountered by the system before, then the query is passed directly to the plan cache to continue exection.

Execution Engine

The MemSQL execution engine works by invoking a pre-compiled plan built specifically for the query's skeleton. Per-query plan compilation maximizes performance, as it allows the compiler to optimize out the expense of function calls and most jumps.

Without the overhead of dynamically interpreting SQL, MemSQL can execute queries as fast or faster than optimized NoSQL solutions.

Storage Engine

MemSQL's in-memory storage engine is built on two powerful concepts: lock-free data structures and multiversion concurrency control (MVCC). By indexing data with lock-free hashtables and skiplists, MemSQL is the only relational database capable of fully unlocking the parallel nature of modern CPUs. These datastructures, combined with MVCC, ensure that read queries are never blocked by concurrent writes.

Because MemSQL builds a custom plan for every query skeleton, index data structures are inlined directly into query plans, further minimizing the overhead of query exection.

Existing Queries

After MemSQL executes a new type of query, any future query with the same query skeleton is accelerated directly through a hot code path to the pre-compiled execution engine.

New Queries

MemSQL processes new queries through the code generator the first time they run.