DuckDB 2.0 is now on Layerbase
DuckDB 2.0 is now available on Layerbase Cloud, and it is the default for new DuckDB databases. Create a database, open the query console or copy its connection string, and start writing analytical SQL.
You can use it to explore sales data, build reporting queries, investigate product usage, or give an internal tool a hosted analytics database. Layerbase manages the database; you bring the data and the questions.
Update, October 24: Account PostgreSQL and MariaDB sources and managed DuckLake are now available. External PostgreSQL and bring-your-own R2/S3 buckets followed on October 26 as Beta features on Pro and Dedicated. Explore the supported workflows.
A hosted DuckDB you can connect to
DuckDB is often used inside a local script or notebook. On Layerbase, you get a hosted database with a network connection, so your queries can run from your application, a SQL client, or the dashboard.
Create a DuckDB database, name it analytics, and keep version 2.0 selected. The exact engine version is 2.0.0.
For the examples below, open its query console. If you prefer a terminal, copy the connection string from Quick Connect and use it with psql:
# Set DATABASE_URL to the connection string copied from Quick Connect.
psql "$DATABASE_URL"Layerbase serves DuckDB over the PostgreSQL wire protocol. That lets you connect with PostgreSQL clients while executing DuckDB SQL. It does not turn the database into PostgreSQL or make every PostgreSQL extension and ORM feature compatible. The DuckDB connection guide covers connection settings and imports.
Example: find which channels bring in revenue
Suppose you want to compare sales from organic search, email, and paid campaigns. Run these statements in your new analytics database:
CREATE TABLE launch_orders (
order_id INTEGER,
customer_id INTEGER,
ordered_at DATE,
channel VARCHAR,
amount DECIMAL(10, 2)
);
INSERT INTO launch_orders VALUES
(1, 101, '2026-10-01', 'organic', 120.00),
(2, 102, '2026-10-01', 'email', 80.00),
(3, 101, '2026-10-02', 'email', 60.00),
(4, 103, '2026-10-02', 'paid', 200.00),
(5, 104, '2026-10-03', 'organic', 150.00),
(6, 102, '2026-10-03', 'email', 40.00);Now group those orders by channel:
SELECT
channel,
count(*) AS orders,
sum(amount) AS revenue,
round(avg(amount), 2) AS average_order_value
FROM launch_orders
GROUP BY channel
ORDER BY revenue DESC;channel orders revenue average_order_value
organic 2 270.00 135.00
paid 1 200.00 200.00
email 3 180.00 60.00Email generated the most orders, but organic search brought in more revenue. This is the kind of question a reporting page can answer with one query. To investigate profitability, you could add campaign costs and compare them with revenue; order totals alone do not tell you the return on ad spend.
Example: identify repeat customers
Using the same table, find customers who placed more than one order:
SELECT
customer_id,
count(*) AS orders,
sum(amount) AS lifetime_revenue,
min(ordered_at) AS first_order,
max(ordered_at) AS latest_order
FROM launch_orders
GROUP BY customer_id
HAVING count(*) > 1
ORDER BY lifetime_revenue DESC;Customers 101 and 102 appear in the result, with revenue of 180.00 and 120.00 respectively. You could use this query for a customer-success report or as the starting point for a repeat-purchase analysis.
Here, “lifetime” means the history loaded into this table. For a real report, import the full order history you want to measure.
Example: build a daily revenue trend
Window functions let you keep the daily totals and calculate a running total alongside them:
WITH daily_revenue AS (
SELECT ordered_at, sum(amount) AS revenue
FROM launch_orders
GROUP BY ordered_at
)
SELECT
ordered_at,
revenue,
sum(revenue) OVER (
ORDER BY ordered_at
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
) AS cumulative_revenue
FROM daily_revenue
ORDER BY ordered_at;ordered_at revenue cumulative_revenue
2026-10-01 200.00 200.00
2026-10-02 260.00 460.00
2026-10-03 190.00 650.00That result can feed a chart in an internal dashboard or a scheduled report in your own application. These examples use a small dataset so you can run them immediately. You can also bring your own data through the query console's import workflow.
Connect analytics to more of your data
Update, October 24: DuckDB can now query eligible PostgreSQL and MariaDB databases in the same personal account and server container through read-only account sources, including joins across both sources.
Managed DuckLake on Pro and Dedicated uses DuckDB 2, a PostgreSQL metadata catalog, and Parquet data in managed R2. Copy either source into a lake table with SQL and read the saved snapshot later. This is an explicit copy, not automatic replication.
Update, October 26: External PostgreSQL sources and your own Amazon S3 or Cloudflare R2 bucket for lake storage are now available on Pro and Dedicated as Beta features, still a work in progress. The managed storage path still does not require you to supply a bucket.
See the DuckLake overview for setup, supported workflows, and backup and lifecycle limitations, or read Introducing DuckLake on Layerbase.
Existing databases keep their versions
New Cloud databases default to 2.0.0. If you need the 1.x line, select 1.5 in the picker to create a database running 1.5.6; API requests for major version 1 also resolve to 1.5.6.
Existing databases keep their exact versions. Changing the default for new databases does not force an upgrade of your existing data.
Create a DuckDB 2.0 database and try the queries above. You can start with a few rows today, build the reports you need, then explore the connected workflows when you need them.
Keep reading
- The SQL You Already Know Can Help You Grow Your SaaS: A Developer's Guide to DuckDB 2 and DuckLakeDiscover customer trends, understand product usage, and find opportunities for growth using familiar SQL. Follow along for free on Layerbase.
- What developers should know about DuckDBDuckDB is an analytics engine that runs inside your process, reads CSV, JSON and Parquet in place, and attaches PostgreSQL and MySQL as if they were local. Here is what it is good at, where it stops, and what changes when you host it.
- Introducing DuckLake on LayerbaseStart with DuckDB 2, query PostgreSQL and MariaDB together, and save analytical snapshots to DuckLake with managed R2 storage.
- AWS is buying DuckLabs. The check that matters is board composition, not paper.AWS is acquiring the company behind DuckDB and says the project stays free and open source. The articles of association the DuckDB Foundation publishes never mention MIT, and two of its three board seats belong to people who become AWS employees at close.