Benchmark exporting Data from SQLServer to CSV using CLI Tools
In this article, we will compare the performance of various CLI tools for exporting data from SQLServer to CSV format. We will evaluate the speed and efficiency of each tool, providing insights into which one is best suited for different use cases.
CLI are often preferred for data export tasks due to their speed and ability to be easily integrated into scripts and automation workflows. We will focus on three popular tools: FastBCP from arpe.io, BCP, and Export-DbaCsv from dbatools.io.
Tools Compared
- FastBCP: A high-performance data export tool designed for speed and efficiency.
- BCP (Bulk Copy Program): A traditional command-line utility provided by Microsoft for bulk data export.
- dbatools.io Export-DbaCsv: A PowerShell module that offers a convenient way to export data to CSV format.
Benchmarking Methodology
To ensure a fair comparison, we will use the same dataset and export it using each tool under similar conditions. We will measure the time taken for each export operation and analyze the results.
Video Demonstration
To see the performance of each tool in action, watch the following video demonstration:
Results and Analysis
After running the benchmarks, we observed the following results:
Export Time (seconds) — Lower is Better
Volume Exported (GB)
CPU Usage (%) — Reflects Parallelism
Summary Table
| Tool | Time (s) | Volume (GB) | avg CPU (%) during load |
|---|---|---|---|
| FastBCP | 3.3 | 1.7 | 45 |
| BCP | 98 | 3.6 | 2 |
| Export-DbaCsv (dbatools.io) | 19 | 1.9 | 3 |
Volumes gaps can be explained because bcp use UTF-16 encoding by default, which results in larger file sizes compared to UTF-8 encoding used by FastBCP and Export-DbaCsv. FastBCP size is slightly smaller than Export-DbaCsv because it uses a more compact CSV format for DateOnly columns, which save space when exporting large datasets with date columns.
Features comparison for Exporting data
| Feature | FastBCP (arpe.io) | BCP | Export-DbaCsv (dbatools.io) |
|---|---|---|---|
| CSV Export | ✅ | ✅ | ✅ |
| Parallel Export | ✅ | ❌ | ❌ |
| Windows Support | ✅ | ✅ | ✅ |
| Linux Support | ✅ | ✅ | ❌ |
| Cloud Database Support | ✅ | ❌ | ❌ |
| Ease of Use | High | Medium (no header) | High |
| Date Only format support | ✅ | ✅ | ❌ |
| Split Large Source Data | ✅ | ❌ | ❌ |
| Data Driven Partitioning | ✅ | ❌ | ❌ |
| Timepartitioning Support | ✅ | ❌ | ❌ |
| Compression Support for csv | ❌ | ❌ | ✅ |
| Compression Support for parquet | ✅ | ❌ | ❌ |
| Parquet Export | ✅ | ❌ | ❌ |
| Json Export | ✅ | ❌ | ❌ |
| Local File Export | ✅ | ✅ | ✅ |
| AWS S3 Export | ✅ | ❌ | ❌ |
| S3-Compatible Export | ✅ | ❌ | ❌ |
| Azure Blob Storage Export | ✅ | ❌ | ❌ |
| Azure Datalake Gen2 Export | ✅ | ❌ | ❌ |
| Google Cloud Storage Export | ✅ | ❌ | ❌ |
| OneLake Export | ✅ | ❌ | ❌ |
| Open Source | ❌ | ❌ | ✅ |
| Air Gapped | ✅ | ✅ | ✅ |
| Other database support (PostgreSQL, MySQL, Oracle,SAP HANA...) | ✅ | ❌ | ❌ |
| Price | Paid | Free | Free |
Conclusion
In conclusion,
-
FastBCP demonstrates superior performance in terms of export time compared to BCP and Export-DbaCsv, making it an excellent choice for large datasets and time-sensitive operations.
-
However, BCP may be preferred for its wide availability, while Export-DbaCsv offers a user-friendly PowerShell interface with additional features more oriented for DBA.
-
FastBCP has also another advantage for data movement : it allow to export from various sources and to various destinations, which make it a versatile tool for data export tasks.
The choice of tool ultimately depends on the specific requirements of the export task, including dataset size, performance needs, and ease of use.
Resources
- FastBCP: https://fastbcp.arpe.io
- Docs: https://fastbcp.arpe.io/docs/latest/
- Wizard: https://fastbcp.arpe.io/docs/latest/wizard
- FastBCP Free 30-Day Trial:https://arpe.io/get-trial?product=FastBCP
- BCP: https://learn.microsoft.com/en-us/sql/tools/bcp-utility
- Export-DbaCsv: https://dbatools.io/Export-DbaCsv
