# Neon
> Load data from Neon serverless Postgres into MotherDuck with DuckDB's PostgreSQL extension, and run the read against a Neon read replica to keep analytics off your application branch.
Neon is serverless Postgres with branching and autoscaling. Because it's Postgres on the wire, DuckDB's PostgreSQL extension attaches it like any other Postgres database, and everything on [Loading data from Postgres](/key-tasks/loading-data-into-motherduck/loading-data-from-postgres) applies.

## Attach a Neon database

Install and load the `postgres` extension, then attach your Neon connection string. Neon requires TLS, so keep `sslmode=require` in the string:

```sql
INSTALL postgres;
LOAD postgres;
ATTACH 'md:';

ATTACH 'postgresql://<user>:<password>@<endpoint>.neon.tech/<database>?sslmode=require'
    AS neon_db (TYPE postgres, READ_ONLY);

CREATE DATABASE IF NOT EXISTS analytics;

CREATE TABLE analytics.main.orders AS
SELECT * FROM neon_db.public.orders;
```

Attaching read-only is a good default: it makes accidental writes back to your application database impossible.

To avoid putting credentials in the `ATTACH` string, store them in a secret first:

```sql
CREATE SECRET neon_secret (
    TYPE POSTGRES,
    HOST '<endpoint>.neon.tech',
    PORT 5432,
    DATABASE '<database>',
    USER '<user>',
    PASSWORD '<password>'
);

ATTACH '' AS neon_db (TYPE postgres, SECRET neon_secret, READ_ONLY);
```

## Read from a branch or replica

Neon's branching and read replicas both help here:

- **Read replica.** Point the load at a read replica endpoint so a large scan doesn't compete with application traffic on your primary compute.
- **Branch.** Create a branch for the load when you want a stable, point-in-time snapshot of the data, for example for a backfill that has to be reproducible.

Both are separate endpoints in the Neon console, so switching is a connection-string change.

## Load on a schedule

For a recurring load, run the same extract from a [Flight](/concepts/flights) so it executes on MotherDuck compute on a cron rather than on a machine you maintain. The [Postgres ingest Flight recipe](/cookbook/flight-postgres-ingest) is a ready-made starting point: point it at your Neon endpoint and store the credentials as a Flight secret.

For append-only tables, extract incrementally with a watermark instead of reloading the table. See [Data loading patterns](/key-tasks/loading-data-into-motherduck/loading-patterns).

## Things to know

- **Compute cold starts.** A Neon compute that has scaled to zero takes a moment to wake up, so the first query of a scheduled load can be slow or time out. Retry once rather than treating it as a failure.
- **`pg_duckdb` is not available on Neon.** The [pg_duckdb](/concepts/pgduckdb) route, where Postgres itself connects out to MotherDuck, needs the extension installed server-side. Neon's [extension list](https://neon.com/docs/extensions/extension-explorer) doesn't include it, so use the DuckDB-side `ATTACH` above instead. For a comparison, [PlanetScale](/integrations/databases/planetscale) does offer `pg_duckdb`.
- **Row-by-row transfer has a ceiling.** The `postgres` extension is well-suited to one-time loads and backfills. For continuous replication of a busy table, use a change-data-capture tool such as [Estuary](/integrations/ingestion/estuary) or [Streamkap](/integrations/ingestion/streamkap).

## Related content

- [PostgreSQL](/integrations/databases/postgres)
- [Loading data from Postgres](/key-tasks/loading-data-into-motherduck/loading-data-from-postgres)
- [Ingest Postgres tables into MotherDuck from a Flight](/cookbook/flight-postgres-ingest)
- [Neon connection documentation](https://neon.com/docs/connect/connect-from-any-app)


---

## 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=%2Fintegrations%2Fdatabases%2Fneon%2F&page_title=Neon&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.
