● 04 · recipe

Bulk-load millions of rows

intermediate 7 min performancescale

Database-native throughput with COPY and LOAD DATA.

Problem: writing tens of millions of INSERT statements and replaying them is slow.

Solution:

# Auto-selects the fastest method for the dialect
dbsprout generate --rows 10000000 --output-format direct \
  --db postgresql://localhost/myapp

# Force a method: auto | copy | load_data | batch
dbsprout generate --output-format direct \
  --db mysql+pymysql://localhost/myapp --insert-method load_data

Why it works: --output-format direct streams rows straight into the target using PostgreSQL COPY or MySQL LOAD DATA (100K+ rows/sec) instead of generating and replaying SQL text. Add --upsert for idempotent insert-or-update loads.