Does scale-to-zero break a long-running upsert?
No, an active connection keeps compute running. It only suspends when idle, so a sync that connects, upserts and disconnects is the pattern that costs least.
Generador de upsert
Nombra tu tabla, clave y columnas y obtén la sentencia que Neon acepta de verdad, con una guarda para que una fila antigua nunca sobrescriba una nueva. Debajo: cómo funciona la mecánica, qué se rompe y cómo Datrise carga Neon de forma incremental.
Las notas técnicas de esta página están en inglés.
Sentencia · INSERT … ON CONFLICT DO UPDATE
INSERT INTO "deals" ("id", "name", "stage", "amount", "owner_id", "updated_at")
SELECT "id", "name", "stage", "amount", "owner_id", "updated_at"
FROM "deals_staging"
ON CONFLICT ("id") DO UPDATE SET
"name" = EXCLUDED."name",
"stage" = EXCLUDED."stage",
"amount" = EXCLUDED."amount",
"owner_id" = EXCLUDED."owner_id",
"updated_at" = EXCLUDED."updated_at"
WHERE "deals"."updated_at" IS NULL
OR "deals"."updated_at" < EXCLUDED."updated_at";Neon runs standard Postgres, so INSERT … ON CONFLICT DO UPDATE works unchanged, with the unique-index requirement and the EXCLUDED row. The difference is operational: compute is separate from storage and suspends after a period of inactivity, so the first statement of a sync pays a cold start, and each connection to a scaled-to-zero endpoint waits for compute to come back.
Batch accordingly. One upsert statement from a staging table per entity is cheap; thousands of single-row upserts spread over an hour keep compute awake and bill for it. Use the pooled connection string (PgBouncer in transaction mode) for many short workers, and the direct string for one long COPY session, because transaction-mode pooling does not support session-level prepared statements.
No, an active connection keeps compute running. It only suspends when idle, so a sync that connects, upserts and disconnects is the pattern that costs least.
Yes. Create a branch from production, run the generated statement there, inspect the result, then run it on main. Branches share storage, so the copy is instant.
Direct for one bulk session with COPY; pooled for many short-lived workers. Prepared statements and session settings do not survive transaction-mode pooling.
Datrise aterriza entidades de CRM y SaaS en Neon con esta misma mecánica, una marca de agua sobre updated-at y columnas tipadas, así que la sentencia de arriba es la que corre por ti. Únete a la lista de espera para acceso anticipado.
Explorar el catálogo de integraciones