Skip to content
Next.js app hosting is now in early beta testing. Request access
In this postDuckDBPostgreSQLMariaDB

Why Is Everyone Suddenly Into DuckDB?

MariaDB ships a DuckDB engine, MySQL has one in the works, and AWS bought DuckLabs. One join across Postgres and MariaDB shows the appeal, and on Layerbase it runs without a connection string.

By Bob Bass5 min read
DuckDBAnalyticsDatabases
A golden duck holds a cable linking the Postgres elephant and MySQL dolphin servers.

Last week Oracle slipped an interesting detail into a MySQL community update. Halfway down the page, in a list that also included binary log improvements and bug fixes, was a DuckDB storage engine. MariaDB users can already install one. What is it about DuckDB that makes people who already have a database want another one inside it? Oracle’s November 17 update · MariaDB 13.0 release announcement

The short answer: DuckDB answers the end-of-quarter question without making you move your data first.

Think about two questions a shop asks of the same orders. At checkout, “Is the last mug still available?” comes down to one item and a transaction. At the end of the quarter, “How many mugs did we sell each week?” means reading a few columns across a lot of orders. DuckDB stores data by column and processes batches of values at a time. That suits the second question. And because the engine runs inside another program, a database vendor can put it behind the SQL connection its customers already use. How MariaDB embeds DuckDB

Where AWS fits in

AWS acquired DuckLabs, the company where DuckDB’s creators and core developers worked. MotherDuck is a separate company that builds a cloud analytics service on DuckDB. The independent DuckDB Foundation continues to steward the open source project under the MIT license. Those names are easy to mix up, but the distinction explains how AWS can employ the core team while MariaDB, Alibaba, MotherDuck and Layerbase each build their own thing with the engine. DuckLabs’ acquisition announcement and closing update · DuckDB’s project FAQ

Whose SQL prompt are you in?

In MariaDB 13.0, the choice can be as small as one table. Install the plugin and you can use ENGINE=DuckDB for a reporting table, keep your orders in InnoDB, and join the two from the MariaDB prompt. MariaDB 13.0.2 went stable in September. At release, the Foundation rated the plugin itself gamma, a useful distinction before you put it on a checkout server. MariaDB’s release and plugin notes

With MySQL, the answer depends on which distribution you run. Alibaba’s AliSQL 8.0.44 includes a DuckDB storage engine. Oracle’s November update puts a DuckDB engine in the work-underway section for upstream MySQL. If you use stock MySQL, that distinction matters. You can try the integration in AliSQL today, or leave your existing server alone and approach it from the other direction: put DuckDB in charge and let it read the databases you already have. AliSQL 8.0.44 release notes · Oracle’s MySQL roadmap update

One question for Postgres and MariaDB

Say the warehouse retired a few products, but orders are still coming in. Which SKUs sold after the warehouse retired them? The checkout service keeps order lines in Postgres. The catalog team keeps retirement dates in MariaDB. Neither database has enough information to answer on its own.

Open a DuckDB session with read access to both. On your own machine that means two ATTACH statements (DuckDB reaches MariaDB through its mysql extension):

sql
ATTACH 'host=localhost dbname=shop' AS sales
  (TYPE postgres, READ_ONLY);
ATTACH 'host=localhost database=catalog' AS catalog
  (TYPE mysql, READ_ONLY);

This example assumes an order_lines table with a sale timestamp and quantity, and a products table with one row per SKU. Use timestamps on the same clock.

sql
SELECT p.sku, sum(o.quantity) AS units_sold_after_retirement
FROM sales.public.order_lines AS o
JOIN catalog.products AS p ON p.sku = o.sku
WHERE o.sold_at > p.retired_at
  AND o.sold_at >= current_date - INTERVAL '7 days'
GROUP BY p.sku
ORDER BY units_sold_after_retirement DESC, p.sku;

The timestamp comparison earns its keep. A mug that sold on Monday and was retired on Tuesday stays off the list. A mug retired on Monday that sold on Tuesday shows up. A product with no retirement date drops out because the comparison with NULL cannot be true. You get a shortlist the catalog team can investigate, without asking either team to export a CSV. DuckDB documented cross-database joins like this back in January 2024. DuckDB’s multi-database walkthrough

Running it on Layerbase without connection strings

DuckDB on Layerbase has this built in. Create a DuckDB database, open its Sources tab, and add your Postgres database as sales and your MariaDB database as catalog. Hit Test on each one. Skip the ATTACH lines, paste the query above into the query console, and it runs as written.

The thing to know is that you never hand DuckDB your application’s login. Layerbase creates a dedicated SELECT-only login for each source and attaches it read-only, so the analytics session can read checkout data but cannot insert, update or delete a row. Removing a source revokes that login and leaves the tables alone. The databases have to be in the same personal account and on the same server container. If your Postgres lives somewhere else, external PostgreSQL sources are in Beta on Pro and Dedicated.

Sources are on every plan, including Free, but count your databases. This example uses three (DuckDB plus two sources), and Free and Solo stop at two, which is enough for DuckDB and one source. Pro is $15/mo with room for ten, and it comes with a 7-day trial.

If you would rather watch it first, the Layerbase walkthrough video runs a DuckDB query across MariaDB, PostgreSQL, CSV and JSON.

When the one-off becomes a daily report

I’d run that query against read replicas for a one-off investigation. Read-only connections still make the source servers do work, and rows still have to reach DuckDB. If the warehouse wants the report refreshed every minute, I’d first measure how much each refresh reads. That’s when keeping a reporting copy may be worth maintaining.

On Layerbase that copy is DuckLake. Turn it on for a DuckDB 2 database and the lake attaches as ducklake, with its catalog in Postgres and its data as Parquet in a private bucket for your account. Saving the shortlist is one statement:

sql
CREATE TABLE ducklake.retired_sales AS
SELECT p.sku, o.sold_at, o.quantity
FROM sales.public.order_lines AS o
JOIN catalog.products AS p ON p.sku = o.sku
WHERE o.sold_at > p.retired_at;

The next person who reads ducklake.retired_sales touches neither checkout nor the catalog. It is an explicit copy, not replication, so you rerun it when you want fresh numbers. DuckLake is on Pro and Dedicated, with lake storage equal to your plan storage. Introducing DuckLake on Layerbase walks through the full setup.

Where the report lives

Sooner or later someone asks where the report should live, and usually it is a teammate with a BI tool open. DuckDB has no network protocol of its own, so a hosted DuckDB on Layerbase answers over the Postgres wire. Their tool connects with its ordinary Postgres connector and nobody installs anything. If you already use a DuckDB client, the native connection reaches the same database over HTTPS. And if your analysis started as a .duckdb file on your laptop, one command puts it online.

If you are comparing hosts, MotherDuck alternatives covers the options, and ClickHouse vs DuckDB covers when you want a server instead of an embedded engine.

A small first step

Pick one question that usually ends with someone emailing a spreadsheet. Attach the two databases it lives in, write the join, and see what comes back. On Layerbase that is a DuckDB database and two entries in Sources: start one here.