The short explanation
DuckDB can make a heavy Magento report dramatically faster without touching the operational database. In my test, the full Magento Orders Report over 1,000,000 orders and 2,000,000 order items dropped from 18.464 seconds on InnoDB to 0.292 seconds when both tables lived in DuckDB snapshots inside the same MariaDB server. That’s a 63.2× improvement for this dataset and this report.
Here’s what you need to know before you read the details:
- What I tested: Magento Open Source 2.4.8-p5 on MariaDB 11.4.13 with the MariaDB DuckDB storage engine 1.5.5.
- What I didn’t change: Magento kept writing every order to InnoDB. DuckDB held read-only analytical copies.
- The biggest lesson: moving only sales_order to DuckDB gave a 2.23× gain. Moving both sales_order and sales_order_item gave 63.2×. You have to move both sides of the analytical join.
- The cost: a full snapshot of 3,000,000 rows took 34.492 seconds to load, roughly the price of two baseline report runs.
- The caveat: this is an experiment on synthetic data in one Docker environment, not a production benchmark.
Why are Magento reports slow on InnoDB?
Magento reports are slow on InnoDB because InnoDB is built to handle one order at a time, and reports ask it to handle millions at once. Let’s face it: those are two very different jobs.
A typical analytical report does a few things InnoDB was never optimized for:
- It scans millions of rows instead of looking up one by primary key.
- It aggregates order items across the whole table.
- It joins large tables together.
- It calculates a dozen financial values per group.
So here’s the question I wanted to answer: does a heavy analytical report really have to run on the same InnoDB tables that handle Magento transactions?
What is the MariaDB DuckDB storage engine?
The MariaDB DuckDB storage engine lets you create DuckDB tables inside a normal MariaDB server and query them with ordinary SQL, right next to your InnoDB tables. DuckDB is a columnar analytical engine. In plain English, it stores data by column instead of by row, so a query that sums base_grand_total across a million orders reads only that column instead of every field of every order.
Here’s what made this experiment easy: it’s not a separate database service. There’s no second server, no new connection string, no new driver. I queried InnoDB and DuckDB tables through the same MariaDB connection.
How do you add DuckDB to a Magento Docker stack?
I started from Mark Shust’s Docker Configuration for Magento, because the database is just a normal Docker Compose service. That meant I could swap only the MariaDB image and leave PHP-FPM, Nginx, and everything else alone. I added one small compose.override.yaml file:
services:
db:
image: ghcr.io/mariadb/duckdb:11.4
After recreating the database container, I checked the available engines:
SELECT VERSION();
SHOW ENGINES;
MariaDB returned the new engine:
DUCKDB YES DuckDB storage engine
That’s it. Three lines of YAML and the back office was open for business.
What was the test environment?
The test ran on a single Docker Compose development stack with one million synthetic Magento orders.
| Component | Value |
| Magento | Magento Open Source 2.4.8-p5 |
| Database server | MariaDB 11.4.13 |
| Analytical engine | DuckDB storage engine 1.5.5 |
| Orders (sales_order) | 1,000,000 |
| Order items (sales_order_item) | 2,000,000 |
| Items per order | 2 (simple products) |
| Environment | Docker Compose development stack |
I generated the data with the Magento performance fixture generator. Let’s be honest about what that means: synthetic data doesn’t look like a real shop. You won’t find the messy mix of statuses, refunds, invoices, and order values you’d see in production. But it does give you real Magento table structures at real scale, and that’s what this test needed.
One more detail matters. I finished generating all the data before building the analytical snapshots, so the dataset didn’t grow during the report tests.
How do you build DuckDB analytical snapshots of Magento tables?
You build them in a separate schema, as structural copies of the source tables with every key and index stripped out, then convert them to DuckDB and bulk-load them. The original Magento tables never change.
Magento kept using InnoDB for its operational tables, with all their normal primary keys, unique constraints, secondary indexes, and foreign keys intact:
magento.sales_order → InnoDB
magento.sales_order_item → InnoDB
Step 1: Create a separate analytics schema
CREATE DATABASE analytics
CHARACTER SET utf8mb4
COLLATE utf8mb4_general_ci;
Step 2: Copy the table structures
CREATE TABLE analytics.sales_order
LIKE magento.sales_order;
CREATE TABLE analytics.sales_order_item
LIKE magento.sales_order_item;
Step 3: Strip keys and indexes
From both copies, I removed:
- AUTO_INCREMENT attributes
- primary keys
- unique keys
- secondary indexes
- foreign-key constraints
Why strip them? Because a columnar engine doesn’t need them for scans, and the copies are read-only. Column names, column order, data types, nullability, and default values all stayed exactly the same.
Step 4: Convert to DuckDB
ALTER TABLE analytics.sales_order
ENGINE=DUCKDB;
ALTER TABLE analytics.sales_order_item
ENGINE=DUCKDB;
Step 5: Load the snapshot
INSERT INTO analytics.sales_order
SELECT * FROM magento.sales_order;
INSERT INTO analytics.sales_order_item
SELECT * FROM magento.sales_order_item;
| Snapshot | Rows | Load time |
| analytics.sales_order | 1,000,000 | 14.333 s |
| analytics.sales_order_item | 2,000,000 | 20.159 s |
| Total | 3,000,000 | 34.492 s |
DuckDB does not receive updates automatically. Magento never writes to these tables. In production you’d need a full refresh, incremental sync, ETL, or change-data capture to keep them current. This experiment tested only an explicit full snapshot.
How do you verify the DuckDB snapshot matches InnoDB?
You compare row counts and control aggregates between the source and the snapshot before you time a single query. Why? Because a faster report that returns a different answer isn’t faster. It’s just wrong sooner.
| Validation metric | InnoDB source | DuckDB snapshot |
| Row count | 1,000,000 | 1,000,000 |
| Distinct entity_id | 1,000,000 | 1,000,000 |
| ID range | 1–1,000,000 | 1–1,000,000 |
| Sum of entity_id | 500,000,500,000 | 500,000,500,000 |
| Sum of grand_total | 25,300,000.0000 | 25,300,000.0000 |
The row counts and control aggregates for sales_order_item matched too. And the final report output was identical in all three storage configurations. Same answer, every time.
Which Magento report was benchmarked?
The benchmark used two complete Magento Orders Report aggregations, not a toy COUNT(*). One grouped the period by created_at, the other by updated_at. Every measured value is the combined time of both queries, and every run processed all 1,000,000 orders and 2,000,000 order items.
The query works in two stages. First, it rolls up order items by order_id:
WITH item_totals AS (
SELECT
order_id,
SUM(qty_ordered - IFNULL(qty_canceled, 0)) AS total_qty_ordered,
SUM(qty_invoiced) AS total_qty_invoiced
FROM sales_order_item
WHERE parent_item_id IS NULL
OR parent_item_id = 0
GROUP BY order_id
)
The filter accepts both NULL and 0 because the Magento performance fixtures use 0 for root-level order items. Then it joins those totals to the orders:
FROM sales_order AS o
INNER JOIN item_totals AS oi
ON oi.order_id = o.entity_id
The report groups by date, store, and order status, and calculates:
- order count
- ordered and invoiced quantities
- income
- revenue and profit
- invoiced and paid amounts
- canceled and refunded amounts
- tax
- shipping
- discounts
One deliberate change: I removed Magento’s standard filter that excludes new and pending_payment orders, so every generated order took part. The full SQL is in the appendix at the end of this article. For the InnoDB runs, only the schema of the two tables changed. Fields, expressions, grouping, and ordering stayed the same.
How much faster was DuckDB? The benchmark results
With both tables on DuckDB, the two-query Orders Report finished in 0.292 seconds, compared with 18.464 seconds on InnoDB: 63.2× faster.
| Storage configuration | sales_order | sales_order_item | Time for both queries | Relative speed |
| Point 1: baseline | InnoDB | InnoDB | 18.464 s | 1.0× |
| Point 2: orders moved | DuckDB | InnoDB | 8.267 s | 2.23× |
| Point 3: both moved | DuckDB | DuckDB | 0.292 s | 63.2× |
What do those numbers mean in practice? At the baseline, someone clicking “refresh” on this report waits long enough to check their phone. At Point 3, the answer is back before they’ve taken their finger off the mouse. That’s the difference between a report people avoid and a report people actually use.
Point 1 (both on InnoDB) is the original Magento storage, with all of Magento’s normal indexes in place.
Point 2 (orders on DuckDB, items on InnoDB) cut the time by more than half. Good, but the report still needed over eight seconds.
Point 3 (both on DuckDB) ran the order scan, the item aggregation, and the join entirely in DuckDB, and the combined time dropped to 292 milliseconds.
Why wasn’t moving only sales_order enough?
Moving only sales_order left the report scanning and aggregating 2,000,000 order items in InnoDB, and that became the remaining bottleneck. You only get the big win when both sides of the analytical join live in DuckDB.
Honestly, the middle measurement is my favorite part of this whole experiment. Anyone can show you a before and an after. The in-between point tells you where the time actually goes.
It’s a bit like widening one lane of a two-lane bridge. Traffic gets better, sure. But every car still has to cross the narrow lane at some point, so the jam just moves. Point 2 widened the orders lane. The items lane was still a single, slow, row-by-row InnoDB scan. Only when I widened both did the traffic really flow.
A word of caution, though: this doesn’t mean sales_order_item is the bottleneck for every Magento report. It was the main remaining cost for this report, this generated dataset, and this storage configuration. Your mileage will vary, so measure your own middle point.
Why isn’t COUNT(*) the headline number?
A warmed COUNT(*) over one million orders took about 121 ms on InnoDB and about 0.81 ms on DuckDB, but that’s a party trick, not a benchmark.
| Engine | Warmed COUNT(*), 1,000,000 orders |
| InnoDB | ≈ 121 ms |
| DuckDB | ≈ 0.81 ms |
That gap looks enormous. It’s tempting to put it on a slide and call it a day. Don’t. An unfiltered count can often be answered straight from storage-engine metadata. There’s no item aggregation, no join, no financial math, no grouping. It tells you almost nothing about how a real report will behave.
That’s why the complete Orders Report is the headline here. The count is just a side note.
Is the snapshot worth the cost?
In this test, a full snapshot paid for itself after about two report runs. Loading both snapshots took 34.492 seconds, and each run of the report on DuckDB saved about 18.172 seconds (18.464 − 0.292).
So if your team runs this report once a week, a nightly full snapshot is a bad trade. If a dozen managers hit it every morning, it’s a bargain.
But let’s not oversell a back-of-the-envelope calculation. A real snapshot process carries costs that never showed up in my stopwatch:
- extraction from the operational database
- consistency control
- network transfer
- scheduling
- validation
- recovery from failed jobs
Build those into your business case before you promise anyone a 63× speedup.
What are the limitations of this experiment?
This was an experiment, not a formal production benchmark, and I want to be upfront about every place it could mislead you.
- The data came from Magento performance fixtures, not a real store.
- Only one machine and one Docker environment were used.
- Only one report shape was tested.
- The cache state wasn’t formally controlled.
- The measurements include client invocation overhead.
- Concurrent report users weren’t tested.
- DuckDB snapshots had no keys or indexes, while InnoDB kept Magento’s normal indexes.
- Synchronization was a manual full snapshot, and real-time updates weren’t tested.
- CPU and memory usage weren’t recorded under a formal protocol.
So what’s the right way to quote this result?
Correct: the tested report was 63.2× faster in this environment, for this generated dataset and this query shape.
Incorrect: DuckDB makes every Magento report 63× faster.
What’s next: can InnoDB and DuckDB be written in one transaction?
The next thing I want to test is a synchronous dual write: Magento writes an order and its items to InnoDB, and the same transaction fills the DuckDB tables before it commits. If it works, the snapshot delay disappears.
Here’s a simplified sketch. It’s not a ready Magento implementation; the real version has to live inside Magento’s order-saving transaction and copy rows only after their InnoDB IDs exist.
START TRANSACTION;
INSERT INTO magento.sales_order (...);
SET @order_id = LAST_INSERT_ID();
INSERT INTO magento.sales_order_item (...);
INSERT INTO analytics.sales_order (...)
SELECT ...
FROM magento.sales_order
WHERE entity_id = @order_id;
INSERT INTO analytics.sales_order_item (...)
SELECT ...
FROM magento.sales_order_item
WHERE order_id = @order_id;
COMMIT;
There’s a catch, of course. This ties order processing to your analytical storage. A slow DuckDB write makes checkout slower. A failed one can sink the whole transaction. Is that a trade you’d make for real-time reports? I don’t know yet.
And I’m not going to assume that a transaction spanning InnoDB and the MariaDB DuckDB engine is atomic in every failure case. That has to be proven with successful commits, explicit rollbacks, an injected error during the DuckDB insert, and a dropped connection. After each test, both schemas must hold either all of the order’s rows or none of them.
Here’s the full test plan:
- Test synchronous writes to InnoDB and DuckDB inside the same transaction.
- Verify cross-engine COMMIT and ROLLBACK behavior with injected failures.
- Measure how synchronous DuckDB writes change Magento order creation time.
- Run every reporting configuration several times and calculate the median and p95.
- Separate cold-cache and warm-cache measurements.
- Record CPU and memory usage.
- Test several concurrent report users.
- Compare synchronous dual writes with an incremental snapshot refresh.
- Test a replicated environment with a separate DuckDB instance for reports.
- Test reports with invoices, shipments, and customers.
- Use a more realistic distribution of dates, statuses, and amounts.
- Compare InnoDB and DuckDB table sizes.
- Test behavior after a MariaDB restart.
- Compare the MariaDB storage engine with standalone DuckDB.
Conclusion
The MariaDB DuckDB storage engine can work as an analytical layer right beside the Magento operational database, and in this test it turned an 18-second report into a 0.3-second one.
Magento kept running on InnoDB. I didn’t change the engine of a single core table, and I didn’t send a single Magento write to DuckDB. The cashier stayed at the register. The accountant just got a much better office.
To recap the three points:
- InnoDB orders and items: 18.464 seconds.
- DuckDB orders, InnoDB items: 8.267 seconds.
- DuckDB orders and items: 0.292 seconds.
If you take one thing away, make it the middle number. It shows that moving half the workload buys you half a solution. Find every large table your report touches, and move them together.
Is this ready for production? Not yet. It still needs controlled benchmarks, automatic synchronization, monitoring, and failure recovery. But as a foundation for snapshot-based Magento analytics, it’s one of the most promising things I’ve tried. So, are you ready to measure your own middle point?
Full SQL for the DuckDB benchmark
This is the complete first report query, run against the DuckDB tables in the analytics schema. The second query is identical except that it uses o.updated_at instead of o.created_at in both the SELECT and the GROUP BY. For the InnoDB runs, only the schema of sales_order and sales_order_item changed.
WITH item_totals AS (
SELECT
order_id,
SUM(qty_ordered - IFNULL(qty_canceled, 0)) AS total_qty_ordered,
SUM(qty_invoiced) AS total_qty_invoiced
FROM analytics.sales_order_item
WHERE parent_item_id IS NULL OR parent_item_id = 0
GROUP BY order_id
)
SELECT
CAST(o.created_at AS DATE) AS period,
o.store_id,
o.status AS order_status,
COUNT(o.entity_id) AS orders_count,
SUM(oi.total_qty_ordered) AS total_qty_ordered,
SUM(oi.total_qty_invoiced) AS total_qty_invoiced,
SUM(
(IFNULL(o.base_grand_total, 0) - IFNULL(o.base_total_canceled, 0))
* IFNULL(o.base_to_global_rate, 0)
) AS total_income_amount,
SUM(
(
IFNULL(o.base_total_invoiced, 0)
- IFNULL(o.base_tax_invoiced, 0)
- IFNULL(o.base_shipping_invoiced, 0)
- (
IFNULL(o.base_total_refunded, 0)
- IFNULL(o.base_tax_refunded, 0)
- IFNULL(o.base_shipping_refunded, 0)
)
) * IFNULL(o.base_to_global_rate, 0)
) AS total_revenue_amount,
SUM(
(
IFNULL(o.base_total_paid, 0)
- IFNULL(o.base_total_refunded, 0)
- IFNULL(o.base_tax_invoiced, 0)
- IFNULL(o.base_shipping_invoiced, 0)
- IFNULL(o.base_total_invoiced_cost, 0)
) * IFNULL(o.base_to_global_rate, 0)
) AS total_profit_amount,
SUM(IFNULL(o.base_total_invoiced, 0) * IFNULL(o.base_to_global_rate, 0)) AS total_invoiced_amount,
SUM(IFNULL(o.base_total_canceled, 0) * IFNULL(o.base_to_global_rate, 0)) AS total_canceled_amount,
SUM(IFNULL(o.base_total_paid, 0) * IFNULL(o.base_to_global_rate, 0)) AS total_paid_amount,
SUM(IFNULL(o.base_total_refunded, 0) * IFNULL(o.base_to_global_rate, 0)) AS total_refunded_amount,
SUM(
(IFNULL(o.base_tax_amount, 0) - IFNULL(o.base_tax_canceled, 0))
* IFNULL(o.base_to_global_rate, 0)
) AS total_tax_amount,
SUM(
(IFNULL(o.base_tax_invoiced, 0) - IFNULL(o.base_tax_refunded, 0))
* IFNULL(o.base_to_global_rate, 0)
) AS total_tax_amount_actual,
SUM(
(IFNULL(o.base_shipping_amount, 0) - IFNULL(o.base_shipping_canceled, 0))
* IFNULL(o.base_to_global_rate, 0)
) AS total_shipping_amount,
SUM(
(IFNULL(o.base_shipping_invoiced, 0) - IFNULL(o.base_shipping_refunded, 0))
* IFNULL(o.base_to_global_rate, 0)
) AS total_shipping_amount_actual,
SUM(
(ABS(IFNULL(o.base_discount_amount, 0)) - IFNULL(o.base_discount_canceled, 0))
* IFNULL(o.base_to_global_rate, 0)
) AS total_discount_amount,
SUM(
(IFNULL(o.base_discount_invoiced, 0) - IFNULL(o.base_discount_refunded, 0))
* IFNULL(o.base_to_global_rate, 0)
) AS total_discount_amount_actual
FROM analytics.sales_order AS o
INNER JOIN item_totals AS oi ON oi.order_id = o.entity_id
GROUP BY CAST(o.created_at AS DATE), o.store_id, o.status
ORDER BY period, o.store_id, o.status;
Frequently Asked Questions
No, and this experiment didn't try. Magento needs InnoDB's transactions, indexes, foreign keys, and crash recovery for orders, invoices, and refunds. DuckDB was used only for read-only analytical copies.
No. The MariaDB DuckDB storage engine runs inside MariaDB. You create tables with ENGINE=DUCKDB and query them over the same connection as your InnoDB tables. In a Docker stack, swapping the image to ghcr.io/mariadb/duckdb:11.4 was the only change.
In this test, the Magento Orders Report over 1,000,000 orders and 2,000,000 items ran 63.2× faster: 0.292 seconds versus 18.464 seconds. Results will differ for other reports, data distributions, and hardware.
Move every large table the report joins, not just one. Moving only sales_order gave 2.23×. Moving sales_order and sales_order_item together gave 63.2×
No. In this setup, DuckDB tables are snapshots. You need a full refresh, incremental sync, ETL, change-data capture, or a dual-write approach to keep them current.
Loading 1,000,000 orders took 14.333 seconds, and 2,000,000 order items took 20.159 seconds, for a total of 34.492 seconds in this environment.
In this experiment, they were removed: AUTO_INCREMENT, primary keys, unique keys, secondary indexes, and foreign keys. Column definitions stayed identical so INSERT ... SELECT * worked directly.
Reports that don't need data from the current second: daily sales reports, management dashboards, long-period revenue analysis, BI queries, and ad hoc analytics.
