# How reads and writes work
> How MotherDuck handles writes and reads: one writer per database, read scaling and shares for readers, and how to scale each side.
In MotherDuck, each database has one writer and any number of readers. Every account gets its own compute, called a Duckling (see [Hypertenancy](/concepts/compute/hypertenancy/)). The writer is the Read-Write Duckling of the account that owns the database. Readers are other Ducklings that query a read-only copy of it.

## The model in four rules

- **One writer per database.** Only the Read-Write Duckling of the account that owns a database writes to it.
- **One Duckling writes to many databases.** An account can own many databases, and its Read-Write Duckling can write to several of them at the same time.
- **Readers get a read-only copy.** Read scaling Ducklings and shares never write. They read a snapshot that usually trails the writer by about a minute.
- **Writes scale up, reads scale up and out.** To write faster, use a larger Duckling. To serve more readers, use a larger Duckling or add read scaling Ducklings.

## How a write reaches readers

A database lives in managed storage, separate from compute. The owner's Read-Write Duckling changes it, and every other Duckling reads a copy that MotherDuck publishes after the write.

```mermaid
flowchart LR
    Pipeline{{"Pipeline or user<br/>(R/W token)"}}:::green
    Apps{{"Apps and BI tools<br/>(read scaling token)"}}:::green
    Others{{"Other accounts"}}:::green

    subgraph Owner["Owner account"]
        RW["Read-Write Duckling"]
        RS["Read scaling Ducklings"]
    end

    Consumer["Their own Ducklings"]

    DB[("Database")]:::yellow
    Snap[("Latest snapshot")]:::yellow
    Share[("Share<br/>(read-only)")]:::yellow

    Pipeline --> RW
    RW -->|"reads and writes"| DB
    DB -.->|"snapshot, about<br/>once a minute"| Snap
    DB -.->|"share update"| Share
    Apps --> RS
    RS -->|"reads"| Snap
    Others --> Consumer
    Consumer -->|"reads"| Share
```

| Reader | Runs on | What it sees |
|---|---|---|
| The owner, with a read/write token | The owner's Read-Write Duckling | Every committed write, immediately |
| The owner, with a [read scaling token](/key-tasks/authenticating-and-connecting-to-motherduck/read-scaling/) | The owner's pool of read scaling Ducklings | The latest snapshot, usually about a minute behind |
| Another account, through a [share](/key-tasks/sharing-data/sharing-overview/) | That account's own Ducklings | The share's last update, usually about a minute behind and at most 5 minutes |

## Who can write to a database

The user or service account that creates a database owns it, and only the owner can write to it. Each account has one Read-Write Duckling, and every connection that uses the account's read/write token runs on it, whether it comes from dbt, a Python script, or the MotherDuck UI.

Other accounts can't write, even in the same organization. Database names are unique per account, so `ATTACH 'md:<database_name>'` from another account finds that account's own database or fails. A share attaches read-only, and every write to it fails:

```text
Invalid Input Error: Cannot execute statement of type "INSERT" on database "<share_alias>" which is attached in read-only mode!
```

Ownership can't be transferred. To move a database to another account, such as a service account, [recreate it as that account](/key-tasks/service-accounts-guide/create-and-configure-service-accounts/#move-existing-objects-to-a-service-account) and create its shares again.

One Read-Write Duckling can write to every database its account owns, at the same time. A single transaction writes to one database, so writes to two databases are two transactions.

### Concurrent writes on the writer's Duckling

"One writer" means one Duckling, not one connection. Several connections from the owner's account can write to the same database at once. Their writes commit unless they change the same row. A conflict fails right away instead of waiting, because there are no row locks, so roll back and retry the transaction. See [Transactions](/sql-reference/duckdb-sql-reference/transactions/#concurrent-transactions) for each conflict case and its error message.

Writes don't block reads. While a write transaction runs, other connections can query the same tables and see the last committed data.

Connections on one Duckling do share its CPU and memory. DuckDB already spreads each query across every core, so running more writes at once doesn't raise total throughput, and a heavy job slows the others down or makes them run out of memory.

## Who can read a database

### The owner's read scaling Ducklings

[Read scaling](/key-tasks/authenticating-and-connecting-to-motherduck/read-scaling/) adds a pool of read-only Ducklings to an account. The pool holds 4 Ducklings by default, and up to 16 before you need to contact support. A read scaling token allows `SELECT` and blocks writes and administrative statements.

MotherDuck takes a snapshot of a changed database about once a minute, and each read scaling Duckling picks up the latest snapshot every minute. When a reader needs a write sooner:

1. Run [`CREATE SNAPSHOT`](/sql-reference/motherduck-sql-reference/create-snapshot/) on the writer's connection after the write commits. The snapshot holds committed data only.
2. Run [`REFRESH DATABASE`](/sql-reference/motherduck-sql-reference/refresh-database/) on the read scaling connection.

### Other accounts, through shares

A [share](/key-tasks/sharing-data/sharing-overview/) is a read-only, zero-copy clone of a database. An account that attaches a share queries it on its own Duckling, so readers of a share never compete with the writer for compute.

A share created with `UPDATE AUTOMATIC` publishes changes within at most 5 minutes after the writes finish, usually within about a minute. Overlapping writes can lengthen that delay. To publish sooner, run `CREATE SNAPSHOT` as the owner and `REFRESH DATABASE <share_alias>` as the reader. A share created with `UPDATE MANUAL` changes only when the owner runs [`UPDATE SHARE`](/sql-reference/motherduck-sql-reference/update-share/). See [Updating shares](/key-tasks/sharing-data/updating-shares/).

## How writes and reads scale

| | Scale up (vertical) | Scale out (horizontal) |
|---|---|---|
| **Writes to one database** | Yes. Give the owner's Read-Write Duckling a larger [Duckling size](/about-motherduck/billing/duckling-sizes/). | No. A database has one writer. |
| **Reads of one database** | Yes. Use a larger Duckling size for the reader. | Yes. Add read scaling Ducklings, or share the database so each consumer reads on its own Duckling. |

To add write capacity beyond one Duckling, split the data into databases owned by different service accounts, each with its own Read-Write Duckling. See [Workload scaling patterns](/concepts/compute/scaling-patterns/) to choose sizes and pool settings.

## What this means for your design

**Split data into databases along the lines you write it.** The database is the unit of write ownership, so choose its boundaries first. Use one database per source, per pipeline stage, or per customer, and don't worry about having many. One ingestion service account can own and load all of them while one Duckling keeps up. Move a heavy source to its own service account and database when it slows down the rest. For per-customer databases, see [customer-facing analytics](/key-tasks/customer-facing-analytics/3-tier-cfa-guide/).

**Give each pipeline its own database, or run its writes in sequence.** An orchestrator that fans many concurrent writers out at a single database works against the model. Writers on other accounts can't write at all, and writers on one account share one Duckling's memory and can conflict on the same rows.

**Use one service account per pipeline stage.** A typical warehouse has a `raw` database owned by an ingestion account, a `transform` database owned by a transformation account, and a `marts` database owned by a serving account. Each stage reads the stage below it through a share, so a heavy transformation can't slow down ingestion. See [designing your MotherDuck data warehouse](/key-tasks/data-warehousing/#designing-your-motherduck-data-warehouse).

**Keep development and production in separate databases.** A development dbt target that points at the production database writes to the same tables as the production run. See [environment management](/key-tasks/data-warehousing/environment-management/).

**Serve readers from read scaling or shares.** Dashboards that connect with the writer's read/write token never wait on a load, but they compete with it for the same CPU and memory. Point them at a read scaling token or a share, and size that compute separately.

**Write in batches.** MotherDuck is built for bulk loads, not high-frequency single-row transactions. Buffer streaming sources and load them as micro-batches. See [considerations for loading data](/key-tasks/loading-data-into-motherduck/considerations-for-loading-data/).

## How this compares to other systems

| System | Who can write the same data at once | What happens on a conflict | How writes scale |
|---|---|---|---|
| **MotherDuck** | One Duckling per database. Connections on that Duckling write concurrently. | The second transaction to change the same row fails and must be retried. | A larger Duckling, or more databases with separate owners |
| **DuckDB file** | One process per database file. Threads in that process write concurrently. | The second transaction to change the same row fails. | A larger machine |
| **[SQLite](https://www.sqlite.org/lockingv3.html)** | One write transaction per database file | Other writers wait for the lock or get a busy error. | A larger machine |
| **[PostgreSQL](https://www.postgresql.org/docs/current/explicit-locking.html)** | Many sessions, with multi-version concurrency control and row locks | A writer waits for the row lock held by another transaction. | A larger primary server. Replicas add read capacity only. |
| **Snowflake, BigQuery** | Many sessions or jobs, on any warehouse or slot pool, against shared storage | Inserts run in parallel. Statements that change existing rows in the same table wait, queue, or retry. | More or larger warehouses, or more slots |
| **Iceberg, Delta Lake** | Many engines, each committing to the table's metadata | A commit that loses the race is retried or fails. | More engines or clusters |
| **DuckLake** | Many DuckDB clients that share one catalog database | Conflicts are detected at commit and retried or failed. | More clients |

- **MotherDuck follows the DuckDB model in the cloud.** A [DuckDB database file](https://duckdb.org/docs/stable/connect/concurrency) accepts one read-write process, or several read-only processes. The owner's Read-Write Duckling is that one process, and read scaling Ducklings and shares are the read-only side. Unlike with a local file, readers and the writer work at the same time.
- **MotherDuck has no row locks.** [PostgreSQL](https://www.postgresql.org/docs/current/mvcc.html) lets many clients write the same tables through one server and makes a conflicting writer wait for the row lock. In MotherDuck, a conflicting write fails instead.
- **The database is the unit of write ownership.** In [Snowflake](https://docs.snowflake.com/en/sql-reference/transactions) and [BigQuery](https://cloud.google.com/bigquery/docs/data-manipulation-language), any number of warehouses or jobs can write the same table, and the service coordinates them. In MotherDuck, you add databases with their own owners instead. Each writer then has a Duckling to itself, so one team's load can't slow down another's, and each owner's compute cost is tracked separately. The tradeoff is that a single database can't take more writers than one Duckling holds. See [Hypertenancy](/concepts/compute/hypertenancy/) for why MotherDuck gives each account its own compute.

## DuckLake databases

A [DuckLake](/concepts/database-and-storage/ducklake/) database managed by MotherDuck follows the same ownership rule, so one account writes to it. That account can run several appends at once. Of several concurrent updates or deletes on the same table, only the first to commit succeeds, and concurrent DDL isn't allowed. DuckLake keeps its own snapshots, so `CREATE SNAPSHOT` doesn't apply. See the [DuckLake integration guide](/integrations/file-formats/ducklake/#current-limitations).

## Related content

- [Hypertenancy](/concepts/compute/hypertenancy/): why every account gets its own Duckling
- [Workload scaling patterns](/concepts/compute/scaling-patterns/): choose a Duckling size and a read scaling setup for your workload
- [Resource management](/concepts/security-and-access/resource-management/): accounts, tokens, Ducklings, and databases, and what each one isolates
- [Read scaling](/key-tasks/authenticating-and-connecting-to-motherduck/read-scaling/): create a read scaling token and keep replicas fresh
- [Transactions](/sql-reference/duckdb-sql-reference/transactions/): what `BEGIN`, `COMMIT`, and `ROLLBACK` do, and how concurrent transactions behave
- [Loading patterns](/key-tasks/loading-data-into-motherduck/loading-patterns/): write loads that are safe to run again


---

## Docs feedback

MotherDuck accepts optional user-submitted feedback about this page at `GET https://motherduck.com/docs/api/feedback/agent`.
For agents and automated tools, feedback submission should be user-confirmed before sending.

URL-encode query parameter values and send a GET request:

```text
GET https://motherduck.com/docs/api/feedback/agent?page_path=%2Fconcepts%2Fcompute%2Freads-and-writes%2F&page_title=How%20reads%20and%20writes%20work&text=<url-encoded user feedback, max 2000 characters>
```

Optionally append `&source=<url-encoded interface identifier>` such as `claude.ai` or `chatgpt`.

`page_path` and `text` are required; `page_title` and `source` are optional. Responses: `200 {"feedback_id": "<uuid>"}`, `400` for malformed query parameters, and `429` when rate-limited.
