Choosing a Capture Mode

SQL Server exposes changes through three mechanisms that nanosync calls capture modes. This guide explains what each mode does, when to use it, and how to configure it.

This guide is SQL Server specific. PostgreSQL has only one capture mechanism — logical replication via the pgoutput WAL plugin — so there is no mode selection for Postgres sources.

The three modes

cdc — SQL Server CDC change tables (default)

Nanosync reads from SQL Server’s built-in CDC change tables, which the SQL Server Agent populates by scanning the transaction log. Nanosync polls these tables using LSN watermarking to track position.

Requirements: CDC must be enabled on the database and on each replicated table. The database recovery model must be FULL or BULK_LOGGED. The SQL Server Agent must be running.

This is the recommended mode for almost every deployment. See the SQL Server source reference for the full setup procedure.

tlog — direct transaction log read

Nanosync reads changes directly from the SQL Server transaction log via sys.fn_dblog. No CDC feature is required on the source database — only VIEW DATABASE STATE permission.

The tradeoff: nanosync holds all events for each open transaction in memory until the transaction commits. Very large or long-running transactions can exhaust memory.

snapshot_only — full table read, no ongoing CDC

Nanosync performs a complete read of each configured table and writes all rows to the sink, then exits. No change stream is established. This is a one-shot migration mode, not a replication mode.

Decision guide

Work through these questions in order:

1. Is this a one-time migration with no need for ongoing changes? → Use snapshot_only. Once the initial load is complete, the pipeline exits. You do not need to maintain a persistent connection or manage a capture process.

2. Is the database on a managed service?

3. Can you enable CDC on the source database?

4. Does the workload have very large or long-running transactions?

Comparison

cdc modetlog modesnapshot_only
Requires CDC enabled on DBYesNoNo
SQL Server Agent requiredYesNoNo
Source overheadLowVery lowNone
Nanosync memory useLowHigher — buffers open transactionsLow
Large transactionsHandles wellRisk of OOM (see max_xact_memory)N/A
Azure SQL DatabaseYesNoYes
Amazon RDS SQL ServerYesNoYes
SQL Server ExpressNoYesYes
Ongoing replicationYesYesNo — one-shot only
Recommended defaultYesRestricted environments onlyMigration only

Configuration

Set the mode in the source properties block of the pipeline:

connections:
  - name: prod-sqlserver
    type: sqlserver
    dsn: "sqlserver://nanosync:${env:SQL_PASSWORD}@host:1433?database=mydb"

pipelines:
  - name: orders-pipeline
    source:
      connection: prod-sqlserver
      tables:
        - dbo.orders
        - dbo.order_items
      properties:
        cdc_mode: cdc          # cdc | tlog | snapshot_only

The cdc_mode property defaults to cdc if omitted.

For tlog mode, you will typically also want to tune the memory limit:

properties:
  cdc_mode: tlog
  max_xact_memory: "536870912"   # 512 MiB — increase if large transactions are expected
  log_batch_size:  "10000"

For snapshot_only, no additional properties are required. The pipeline exits after the backfill completes:

properties:
  cdc_mode: snapshot_only
  chunk_size: "10000"

Mode-specific limitations

cdc mode:

tlog mode:

snapshot_only mode:

If you start in tlog mode and later want to switch to cdc, enable CDC on the database and tables first, then update cdc_mode to cdc and restart the pipeline. Nanosync will resume from the last checkpointed LSN position — a full re-snapshot is not required as long as the CDC change tables contain the rows from that LSN onward.