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.sqlAll Commands Support Compression
Section titled “All Commands Support Compression”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 redact backup.sql.gz --hash "*.email" -o safe.sqlsql-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"Compression on Output
Section titled “Compression on Output”sql-splitter does not compress output directly. Use pipes for compressed output:
# Gzip outputsql-splitter merge tables/ | gzip > merged.sql.gz
# 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.bz2Performance 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 --progressStdin with Compression
Section titled “Stdin with Compression”When reading from stdin with -, you can decompress externally:
# Decompress with zcat and pipezcat backup.sql.gz | sql-splitter analyze -
# Or use process substitutionsql-splitter analyze <(zcat backup.sql.gz)However, passing the compressed file directly is simpler and handles buffering better:
sql-splitter analyze backup.sql.gzSee Also
Section titled “See Also”- Unix Piping - Composing commands with pipes
- Performance - Optimization tips