Skip to main content
ANNOUNCEMENTMeet MariaDB Enterprise Platform 2027. Read more.

Menu

WEBINAR

Built for the Agentic Era: Introducing MariaDB Enterprise Platform 2027

Watch now

Product

The place between transactions and analytics – and what it means for you

By Shane Johnson

6 min read
Share

Key takeaways

  • HTAP (hybrid transactional/analytical processing) runs transactional and analytical queries against the same data in one database.
  • Customer-facing applications increasingly need queries that are both: they aggregate many rows to find a few IDs, then look up those rows by primary key.
  • To support HTAP, a database stores the same data in row and columnar formats, keeps the two in sync and routes each query to the right one.

We’ve always classified database queries as transactional or analytical. If our application has transactional queries, we use an OLTP database. If it has analytical queries, we use an OLAP database (or data warehouse).

However, with analytics fast becoming a competitive differentiator for customer-facing web and mobile applications, businesses are discovering the place between transactions and analytics. This is when customer-facing applications need hybrid transactional/analytical processing (HTAP).

What is HTAP?

Hybrid transactional/analytical processing (HTAP) is a database architecture that runs transactional (OLTP) and analytical (OLAP) queries on the same operational data. In a traditional setup, data moves from the transactional database to a data warehouse through ETL jobs that run in scheduled batches, so analytical results lag behind what is happening in the application. 

An HTAP database keeps its analytical data continuously in sync with incoming transactions, which lets an application analyse current data and act on the result in the same workflow.

On one hand you have standard CRUD operations – view a product, add it to a cart and complete a purchase. All of these interactions are performed with transactional queries as part of a customer interaction. They typically need most or all columns in a row, and use indexes to improve performance. They’re row oriented, and are executed on an OLTP database.

On the other, you have a data analyst performing a market basket analysis to improve product recommendations. It’s performed with analytical queries as part of an employee interaction. The queries typically need a small number of columns in a row, and do not use indexes. They’re column oriented, and they would be executed on a separate OLAP database.

Then there is the place between – queries within customer-facing applications that have to sort, filter and aggregate data without the help of indexes. These queries may need to aggregate a column (or a small number of columns) for many rows and use the results to look up a small number of rows in a separate table. They are both column oriented and row oriented. 

For example, say you want to alert customers of the top five soon-to-be-sold-out products based on the quantity in active shopping carts, the quantity in recent purchases (say, the last 24 hours) and current inventory. This query will use sorting, filtering and aggregation to find the product IDs for the top five soon-to-be-sold-out products – column oriented and analytical. It may access many thousands, if not millions, of shopping carts and purchases – all to get the IDs of five products. It will then use them to look up five rows in the products table by product ID (i.e., the primary key) – row oriented and transactional. It’s the space between transactional and analytical, and today it’s a critical component of innovative, customer-facing applications.

What’s needed from the database

To enable ad hoc, near-real-time analytical queries on transactional data, you need a database that does three things – each of which is enabled by MariaDB’s approach to hybrid transactional/analytical processing.

First, it needs to store the same data in two different tables

one with a columnar format to support sorting, filtering and aggregating data without indexes; and one with a row format to support looking up rows based on primary keys or secondary indexes. 

MariaDB Platform is based on workload-optimized storage engines, so it uses the InnoDB or MyRocks storage engines to store data in rows, optimized for transactional queries. And it uses the ColumnStore storage engine to store data in a columnar format, optimized for analytical queries.

Second, it needs to synchronize the two tables

All changes to the row-based table must be replicated to the column-based table. The database uses streaming change-data-capture with micro batching to synchronize the two. 

MariaDB Platform supports cross-engine joins, or the capability to join rows stored in columnar tables to rows in row-based tables. In our example of soon-to-be-sold-out products, it would perform the aggregations using tables with the columnar format, and the lookups on tables using the row format.

Third, it needs to know which tables to use and when

MariaDB Platform uses rules-based query routing to determine which table the query should be sent to. In some cases, it’s a binary choice. If there’s a CRUD operation, the query is routed to the row-based table. If the query cannot use indexes or is performing an aggregate on a small number of columns, it is routed to the column-based table. 

For more on hybrid transactional/analytical processing, watch this on-demand webinar: The Role of Databases in a Hybrid-Everything Future.

FAQ

What is the difference between OLTP and OLAP queries?

OLTP (transactional) queries support customer interactions such as adding a product to a cart. They typically need most or all columns in a row and use indexes. OLAP (analytical) queries support analysis such as market basket analysis. They typically read a small number of columns across many rows, don’t use indexes and traditionally run on a separate OLAP database or data warehouse.

What kind of query falls between transactions and analytics?

These are queries inside customer-facing applications that sort, filter and aggregate many rows without indexes, then use the results to look up a few rows by primary key. An example is finding the top five products about to sell out across active carts, recent purchases and inventory, then retrieving those five product records.

What does a database need to support HTAP?

It needs to store the same data in a row-based format for transactional lookups and a columnar format for analytical queries, keep the two synchronized as data changes, and send each query to the format that suits it.