Compression Support
sql-splitter automatically detects and decompresses compressed input files based on file extension.
Supported Formats
Section titled “Supported Formats”| Format | Extension | Library |
|---|---|---|
| Gzip | .gz | flate2 |
| Bzip2 | .bz2 | bzip2 |
| XZ/LZMA | .xz | xz2 |
| Zstandard | .zst | zstd |
Simply pass a compressed file—no flags needed:
# Gzipsql-splitter split backup.sql.gz -o tables/
# Bzip2sql-splitter analyze database.sql.bz2
# XZsql-splitter validate dump.sql.xz
# Zstandardsql-splitter convert mysql.sql.zst --to postgres -o pg.sqlCommands Supporting Compression
Section titled “Commands Supporting Compression”Nearly every command that accepts an input file supports compressed input:
sql-splitter split backup.sql.gz -o tables/sql-splitter analyze backup.sql.gzsql-splitter merge tables/ -o merged.sql # Note: merge reads directory, not compressed filesql-splitter sample backup.sql.gz --percent 10 -o sample.sqlsql-splitter shard backup.sql.gz --tenant-value 123 -o tenant.sqlsql-splitter convert backup.sql.gz --to postgres -o pg.sqlsql-splitter validate backup.sql.gz --strictsql-splitter diff old.sql.gz new.sql.gzsql-splitter graph backup.sql.gz -o schema.htmlsql-splitter order backup.sql.gz -o ordered.sqlsql-splitter query backup.sql.gz "SELECT COUNT(*) FROM users"Exception: redact does not decompress input. Decompress first, then redact:
zcat backup.sql.gz > backup.sqlsql-splitter redact backup.sql --hash "*.email" -o safe.sqlCompression on Output
Section titled “Compression on Output”sql-splitter does not compress output directly. Use pipes for compressed output:
# Zstandard output (faster, better compression)sql-splitter sample dump.sql --percent 10 | zstd > sample.sql.zst
# Bzip2 outputsql-splitter convert mysql.sql --to postgres | bzip2 > pg.sql.bz2
# Merge and compresssql-splitter merge tables/ | gzip > merged.sql.gzWhen output goes to stdout, status lines are written to stderr, so piped SQL stays clean.
Performance Notes
Section titled “Performance Notes”- Gzip: Good balance of speed and compression, widely supported
- Zstandard: Fastest decompression, excellent compression ratio, recommended for large files
- XZ: Best compression ratio but slower, good for archival
- Bzip2: Moderate speed and compression, legacy format
For best performance with very large dumps, Zstandard (.zst) is recommended:
# Compress with zstd for optimal speedzstd -T0 huge-dump.sql -o huge-dump.sql.zst
# Process compressed filesql-splitter analyze huge-dump.sql.zst --progressNo Stdin Input
Section titled “No Stdin Input”sql-splitter reads from file paths only—- for stdin is not supported, and process substitution (<(zcat ...)) fails because the input is read more than once (dialect detection, then parsing). Pass the compressed file directly instead:
sql-splitter analyze backup.sql.gzSee Also
Section titled “See Also”- Unix Piping - Composing commands with pipes
- Performance - Optimization tips