Skip to content
Chapter 36Lesson 5

Quiz - Postgres on Neon

Quiz progress

0 / 0

Branching a 10 GB Neon database is near-instant and adds almost no storage, while the old pg_dump/restore copy takes minutes and a fresh 10 GB on disk. Which single architectural fact is the root cause of that difference?

Neon separates storage from compute, so a branch is a new stateless compute pointed at a copy-on-write snapshot — it shares the parent’s existing pages and only writes the ones it diverges on.
Neon keeps every branch’s compute warm in advance, so the copy is already running by the time you ask for it.
Neon compresses the parent’s pages before branching, shrinking the 10 GB enough to duplicate it quickly.

A spec says: a user can belong to many projects, and a project can have many users. What shape does this take in a normalized schema?

A junction table (e.g. project_members) holding a foreign key to each side, keyed on the pair of those two columns.
A single project_id foreign-key column on the user table.
A comma-separated project_ids column on user and a user_ids column on project.

The course commits to a Neon dev branch as the default local database rather than Docker Postgres. What is the reasoning, and what does choosing Docker instead cost a student given how the app is wired?

Prod-parity prevents more bugs than offline prevents lost hours, so the default optimizes for parity — and because the app only ever reads DATABASE_URL, a student who prefers Docker changes one variable and loses nothing downstream.
Neon branches are faster to query than a local container, and switching to Docker would require rewriting the queries and schema to target the local Postgres dialect.
Docker can’t run the same migrations as Neon, so a Docker student has to maintain a separate, parallel set of migration files.

Your deploy step runs drizzle-kit migrate, a long stream of ALTER/CREATE statements in one session. A teammate points it at the pooled DATABASE_URL (the -pooler host) to keep it consistent with the app. Why is that the wrong URL, and which client exists for this job?

PgBouncer transaction mode can reclaim the backend at a transaction boundary and sever the migration mid-stream — leaving a half-applied schema — so migrations take the unpooled direct URL via dbUnpooled.
The pooled URL is read-only, so DDL statements silently no-op against it; migrations must use dbUnpooled, which is the only client with write access.
The pooled URL caps queries at one statement per connection, so a multi-statement migration is rejected outright before any change is applied.

A Server Component reads the invoice list to render a page; a Server Action later reads an account balance, decides, then deducts credits and inserts a charge atomically. Match each to its client. Select all that apply.

The Server Component read uses db — the pooled HTTP client: one fetch per query, no held connection.
The Server Action uses dbTx — the WebSocket client over the same pooled URL — because an interactive read-decide-write needs one connection held across several steps.
The Server Action must use the unpooled URL, since any transaction has to skip the pooler to hold its connection.

Quiz complete

Score by topic