đ€ SDA 09: Why We Picked Lakebase
Choosing the operational database for the SDA meant testing transactions, reconnects, governance, ownership, and the boundary between Lakebase and Delta.

In SDA 08, the Synthetic Data Agent learned to remember: requests, plans, runs, approvals, and evidence didnât disappear with the conversation.
That raised a less glamorous question: where should an agent keep the state that coordinates its next move?
This article explains why the choice isnât just a latency chart â itâs about workload, governance, ownership, and executable boundaries.
The decision is narrower than âLakebase is the best database.â Itâs the best fit for the operational control plane the SDA has actually built.
Start With the Workload, Not the Database
The SDA Needs an Operational Control Plane
The state store isnât another analytical repository. It coordinates requests, runs, plan versions, workflow steps, checkpoints, leases, approvals, artifact references, warnings, failures, and retries.
Those records are small, but they change frequently while the application, Databricks jobs, and deterministic tools coordinate the same workflow. The useful operations are ordinary application-database operations:
- Find one request or run by identifier.
- Create a request exactly once when a client retries.
- Update a state projection only if its version is still current.
- Acquire a lease before a worker executes a step.
- Renew that lease without letting another worker take the same work.
- Record a failed attempt without erasing it when a retry starts.
- Approve a plan without rewriting the earlier decision.
- Commit a step checkpoint together with its artifact references.
That workload wants short transactions, indexed point lookups, enforced relationships, conditional writes, and safe concurrency. It looks like an operational PostgreSQL workload.
The SDA doesnât need another place to store synthetic tables. It needs a database that can safely decide what the system is allowed to do next.
Analytical Evidence Has a Different Shape
Profiles, histograms, categorical distributions, relationship metrics, pattern evidence, validation details, generated datasets, and long-term quality histories are different artifacts. They are larger, mostly immutable or append-oriented, and naturally processed through Spark and SQL.
Those artifacts remain in Unity Catalog and Delta. The state store keeps their operational index: an artifact ID, source snapshot, configuration fingerprint, location, status, and compact summary. It doesnât copy every histogram bucket into a run table.
This is the boundary introduced in SDA 08:
Lakebase remembers what the workflow is doing and which evidence it is allowed to use. Delta preserves the evidence of what the system learned and produced.
The boundary is now encoded in src/sda/lakebase_decision.py. The code gives operational ownership to requests, runs, plans, steps, leases, approvals, feedback, transition history, audit events, and artifact references.
It gives analytical ownership to profiles, distributions, relationship evidence, pattern evidence, validation detail, generated datasets, and historical quality and cost analytics.
It also names three things that donât belong in the operational store:
- Raw source rows
- Complete histograms
- Generated synthetic tables
Turn Requirements Into Decision Criteria
Before comparing products, we need criteria that describe the work. Otherwise, the decision matrix becomes a retrospective justification for a choice already made.
Transactional Correctness
The state store must be able to:
- Create each logical request once.
- Start a run against a specific plan version.
- Acquire a lease before executing a step.
- Reject an update based on a stale version.
- Preserve a rejected or superseded plan.
- Complete a step and register its output references together.
- Preserve failed attempts instead of resetting their history.
These operations require transactions, constraints, conditional writes, and concurrency controls.
Low query latency is useful only if the result is correct.
Latency and Concurrency
The relevant benchmark isnât a maximum scan-throughput contest. The questions are smaller and more specific:
- How quickly can the application retrieve one state record?
- How quickly can it complete a short state transaction?
- What happens when two workers claim the same stage?
- What happens when a connection is interrupted?
- What latency appears when suspended compute resumes?
Lakebase scale-to-zero closes idle connections and discards session state such as temporary tables, prepared statements, advisory locks, and LISTEN/NOTIFY registrations.
The application must tolerate a new session rather than quietly depending on the old one.
Databricks Integration
The comparison also needs to include the surrounding platform:
- Databricks Apps, jobs, and notebooks.
- Users, groups, service principals, and OAuth.
- Unity Catalog and Delta.
- Declarative Automation Bundles.
- Isolated development, staging, and production environments.
Every additional credential flow, network path, firewall rule, synchronization process, and deployment system is another component to secure and operate.
Governance and Security
We need identity mapping, least-privilege roles, infrastructure permissions, auditability, encryption, private connectivity, and a clear separation between operational state and sensitive analytical evidence.
Lakebase has separate authorization layers. Project permissions control infrastructure operations such as branches and compute. PostgreSQL roles and grants control direct database access. A Unity Catalog registration governs the read-only catalog representation.
These layers complement one another; they arenât automatically synchronized.
The Lakebase Unity Catalog registration documentation is explicit about the boundary:
Registration creates a read-only catalog. Direct writes still go through PostgreSQL access, where PostgreSQL roles remain authoritative.
Delivery and Operational Ownership
The decision includes the full operating model:
- Infrastructure as code and schema migrations.
- Environment isolation.
- Backup and recovery testing.
- Monitoring and connection management.
- Upgrades and incident response.
- Cost ownership and attribution.
A good benchmark result can still produce a poor architecture if the database requires a second delivery platform, duplicated monitoring, bespoke connectivity, and an unclear owner.
Portability and Exit Cost
Platform integration has value, but it also creates coupling.
- We need to know how much of the application remains ordinary PostgreSQL: SQL, drivers, schemas, migrations, and tools.
- We also need to name the Databricks-specific dependencies: OAuth roles, branches, bundle resources, and optional Unity Catalog registration.
âPostgreSQL compatibleâ isnât a reason to skip testing product-specific behavior. Itâs a reason to make the exit path understandable and to test the differences that matter.
Compare the Candidates
Delta Tables
Delta was an attractive option because it already holds the SDAâs evidence plane. It provides ACID transaction guarantees â atomicity, consistency, isolation, and durability â plus schema enforcement, table history, time travel, Unity Catalog governance, and scalable processing through Spark and SQL.
For full profiles, relationship graphs, pattern registries, validation detail, historical metrics, and generated synthetic tables, Delta remains the right choice.
We shouldnât reject Delta using the old claim that it lacks transactions. Databricks now supports transactions spanning multiple statements and tables for qualifying Unity Catalog managed Delta or Iceberg tables with catalog commits enabled.
The feature has requirements: supported table types, supported compute, and transaction-safe operations. DDL and some metadata operations remain outside the transaction boundary, and interactive transactions use more conservative conflict detection.
The more relevant distinction is integrity. Databricks enforces NOT NULL and CHECK constraints, but primary-key, foreign-key, and unique constraints are informational rather than enforced.
None of this makes Delta inferior. It makes the boundary clearer. A Delta table can represent many state-machine patterns with MERGE, optimistic concurrency, and transactions. The question is whether those patterns are the most natural way to implement a small application run store with enforced relational identity, point updates, leases, and retries.
For the SDA, Delta was retained for the work it handles best. Using it for every layer would remove one technology name while making the operational repository less natural and more constrained.
External Managed PostgreSQL
External PostgreSQL isnât a weak alternative. PostgreSQL provides mature transaction and concurrency semantics, standard client interfaces, extensive operational tooling, and familiar patterns for monitoring, backup, high availability, and replication.
It would be the right choice in an organization that already has a managed PostgreSQL platform, approved extensions, standard network patterns, and a database team that owns migrations and incidents. It would also be a good choice if most applications and users lived outside Databricks.
The cost is architectural rather than merely financial. An external service adds another platform boundary:
- Separate provisioning and deployment.
- Independent networking and private endpoints.
- Another identity, credential, and secret lifecycle.
- Database permissions outside the Databricks model.
- Separate monitoring, backup testing, and incident response.
- Another ownership agreement between the application, data platform, security, and database teams.
None of that is inherently bad. Mature organizations operate these controls successfully every day. For this project, however, the additional boundary would add work without improving profiling, generation, or validation.
External PostgreSQL remains a credible alternative. It didnât lose because itâs a worse database. It lost because the SDA team doesnât already have a separate database platform whose existing value outweighs the integration cost.
Lakebase Postgres Autoscaling
Lakebase supplies a managed PostgreSQL service integrated with Databricks. That makes it a natural home for the SDAâs operational state: short transactions, constraints, indexed lookups, workflow records, and concurrent state changes.
This is the fundamental reason for the choice. Autoscaling, scale-to-zero, branching, OAuth roles, and bundle resources support the decision. They donât replace workload fit.
Less Application Plumbing
Databricks Apps can add a Lakebase resource. The App uses its service principal; Databricks creates a matching PostgreSQL role and injects connection settings such as PGHOST, PGDATABASE, PGUSER, and PGSSLMODE.
The SDAâs LakebaseConnectionConfig.from_environment consumes those non-secret settings. Token acquisition remains lazy, so a new connection can ask for a fresh credential instead of holding a token forever.
The same adapter can use a standard PostgreSQL DSN â a database connection string â for jobs and local acceptance. connect_lakebase calls the token provider on each connection attempt, uses TLS, applies bounded exponential backoff, and retries connection establishment only. It never retries a repository mutation.
Retrying a connection is one problem; repeating an approval insert or state transition is another.
Close to Unity Catalog Without Becoming Delta
A Lakebase database can be registered in Unity Catalog as a read-only catalog. That enables discovery, governed read access, lineage, and cross-source queries beside Delta data. It doesnât turn the registration into the write path.
That gives the SDA a useful hybrid architecture:
- Lakebase handles active requests, runs, approvals, leases, and checkpoints.
- A registered catalog can expose selected operational state for analysis.
- Unity Catalog and Delta retain full profiles, validation evidence, and synthetic outputs.
- Direct PostgreSQL writes continue to use database roles and grants.
Registration is optional for the state repository and isnât claimed as a live acceptance result here.
It Fits the Deployment Model
The SDA has used Declarative Automation Bundles since SDA 03. Lakebase projects, branches, endpoints, roles, and databases are declared in bundle/lakebase.yml alongside the jobs and applications.
The dev target uses an isolated, non-expiring dev branch, a read/write primary endpoint, an OAuth role, and the sda_state database. The root production branch is protected, and the bundle declares a daily snapshot schedule with seven-day retention.
This doesnât replace migrations. The versioned schema in schema/lakebase/001_state_schema.sql is applied explicitly by scripts/apply_state_schema.py, not when the application starts. The schema runner hashes the filename and SQL content, records the result in sda_schema_versions, and makes the second application a no-op.
Test the Decision
The Benchmark Established Viability, Not the Decision
The repository now contains scripts/benchmark_state_store.py. Itâs intentionally small and disposable. It measures the two operations that justify an operational state store:
connect_and_ping: open a fresh PostgreSQL connection and runSELECT 1.request_insert_select_delete: insert one request, read it back, and delete it in one short transaction.
The probe uses a unique request marker and deletes it in a finally block. It never prints the DSN or credential. It isnât a synthetic-data throughput benchmark or a controlled three-way comparison; itâs a workload-specific probe for the operational paths that matter here.
The probe is deliberately workload-specific. It establishes that the chosen connection and transaction paths are viable for the control plane, without pretending to be an SLA â a service-level agreement â or a controlled three-way comparison. It doesnât answer who should own the database, how it should be governed, or whether another platform would be better for a different organization.
The Decision Matrix Without the Spreadsheet
| Criterion | Lakebase Postgres | Delta tables | External PostgreSQL |
|---|---|---|---|
| Transactional state | Best fit for short PostgreSQL transactions, enforced relational constraints, leases, and point updates | ACID is available, but the application-state model is more constrained and key constraints are informational | Strong fit with mature PostgreSQL semantics |
| Analytical scale | Not the destination for complete evidence or generated data | Best fit for profiles, distributions, validation, history, and generated tables | Possible, but would duplicate or complicate the evidence plane |
| Databricks integration | Strong: identities, bundles, branches, endpoints, and Apps stay close to the workflow | Native Unity Catalog and Spark integration | Requires separate networking, credentials, deployment, and monitoring |
| Governance | PostgreSQL roles for direct access; optional read-only Unity Catalog registration; project permissions remain separate | Deepest native Unity Catalog governance for analytical assets | Separate authorization model, with federation if needed |
| Operational ownership | One platform boundary for the SDA team, with explicit database engineering still required | Least infrastructure, but a less natural control-plane workload | Best where a mature database team already exists |
| Portability | Standard PostgreSQL clients reduce exit cost; Databricks OAuth and branches add coupling | Strong analytical portability, but not the chosen state-store semantics | Highest platform independence |
The overall decision is therefore:
Use Lakebase Postgres Autoscaling for the SDAâs operational control plane.
Use Unity Catalog-governed Delta tables for complete analytical artifacts, generated datasets, validation history, quality reporting, cost analysis, and audit datasets.
The benchmark says Lakebase is fast enough for the workload we measured. The architecture says why it is useful in the system we actually have.
Make the Decision an Architectural Contract
An architecture decision is more useful when it can be tested. SDA 09 adds five concrete contracts around the decision.
Contract #1: The Storage Boundary Is Executable
src/sda/lakebase_decision.py names the two storage planes, their record types, their non-goals, and the conditions that should reopen the decision. Tests reject overlapping ownership and verify that raw rows, complete histograms, and generated tables are not operational payloads.
Contract #2: The Connection Path Is Reconnect-Safe
LakebaseConnectionConfig.from_environment reads non-secret connection settings from the variables Databricks Apps expose. environment_token_provider remains lazy. connect_lakebase requests a token for each connection attempt and never logs it.
The behavior is covered by unit tests and by the live connection probe. A fresh connection can recover from an idle endpoint without depending on a permanent session.
Contract #3: The State Schema Is Versioned and Relational
The schema contains 11 sda_* tables, including schema versions, requests, runs, plans, attempts, approvals, feedback, audit events, transition history, run steps, and artifact decisions. Foreign keys and uniqueness constraints are part of the schema rather than comments in an architecture decision record (ADR) â a short document that records why a team chose an option, what boundaries it accepts, and when the decision should be revisited.
Schema application is idempotent, and the cleanup check verifies that disposable state does not remain after the acceptance path.
Contract #4: The Full Lifecycle Is Disposable and Repeatable
scripts/run_sda09_live_lifecycle.py exercises the part of the contract a benchmark cannot see:
- request creation
- run creation and a legal transition
- immutable plan creation
- audit event and approval persistence
- a failed step followed by a successful retry
- a reused artifact decision
- lease acquisition and renewal
- successful attempt completion
The lifecycle acceptance covers the complete path and cleans child history before parent rows, including transition events. Disposable request markers are removed as part of the same repeatable contract.
Contract #5: The Generation Boundary Is Bounded and Testable
SDA 09 doesnât move generated rows into Lakebase, but it does make the existing Delta generation boundary executable. src/sda/generation.py enforces approved plans, deterministic seeds, row-count budgets, schema contracts, receipts, and generation manifests.
The Databricks bundle deploys src/sda/job_entrypoints/generate_spark.py as the standalone Spark writer and src/sda/job_entrypoints/validate_generated_spark.py as its bounded technical gate.
The writer reconstructs the approved plan, verifies its fingerprint, writes a Delta table, and emits a manifest with the run, plan, source snapshot, artifact, receipt, and output fingerprint.
The validation job checks the required schema and expected row count, then persists a versioned validation report in Delta.
The deployed acceptance path verifies the writer, manifest, validator, cleanup, and Unity Catalog boundary. It is a deployment and contract smoke test, not a production-scale capacity claim or a full SDA 10 relational-generation scenario.
Boundaries and Payoff
What This Decision Doesnât Claim
Native integration isnât the same as correctness. Lakebase still has product-specific behavior and limits that must be checked against production requirements.
This article doesnât claim:
- A measured external PostgreSQL competitor result.
- A measured Delta control-plane competitor result.
- Unity Catalog registration of the Lakebase database.
- Production service-principal permissions.
- High availability or cross-region recovery.
- Region availability for every future deployment.
- A production latency or cost SLA.
When Weâd Reopen the Decision
Those arenât hidden failures. Theyâre explicit revisit conditions in ADR 0004, the architecture decision record for this choice: unavailable region, unsupported extension or network control, mandatory independent ownership, failed latency/availability objectives, unmet recovery objectives, consumers moving outside Databricks, or material cost and connection limits.
External PostgreSQL should win if those constraints matter more than platform integration. Delta should continue to win for analytical evidence.
The decision isnât a logo preference and it isnât permanent by ceremony.
The Fastest Component Isnât Always the Simplest System
SDA needed more than durable storage. It needed a transactional control plane that could coordinate concurrent tools, prevent duplicate work, preserve approvals, recover from failures, and expose state through ordinary application patterns.
Lakebase matched that workload while staying close to the Databricks applications and workflows already using it. Delta remained the right home for profiles, validation evidence, historical analytics, and generated tables. External PostgreSQL remained technically sound, but it would have introduced more identity, networking, deployment, and operational boundaries for this project.
The benchmark mattered because Lakebase still had to meet the workloadâs latency and reconnect requirements. Speed established viability. The architecture established usefulness.
The agent now has governed evidence, durable memory, and a database selected for the work rather than the logo. The bounded generator and validator are deployed and verified.
SDA 10 can now extend that path into full relational generation while preserving the distributions and null behavior that make the source data believable.
Lakebase now has a job description, a boundary, and receipts. The next article can build on that without pretending that a benchmark was an architecture.
đ Source Code
The code for this article is available in the SDA-09 branch:
đ synthetic-data-agent
đ§ YouTube playlist
