Rivulet.Sql.PostgreSql
1.3.0
dotnet add package Rivulet.Sql.PostgreSql --version 1.3.0
NuGet\Install-Package Rivulet.Sql.PostgreSql -Version 1.3.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Rivulet.Sql.PostgreSql" Version="1.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Rivulet.Sql.PostgreSql" Version="1.3.0" />
<PackageReference Include="Rivulet.Sql.PostgreSql" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Rivulet.Sql.PostgreSql --version 1.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Rivulet.Sql.PostgreSql, 1.3.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Rivulet.Sql.PostgreSql@1.3.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Rivulet.Sql.PostgreSql&version=1.3.0
#tool nuget:?package=Rivulet.Sql.PostgreSql&version=1.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Rivulet.Sql.PostgreSql
PostgreSQL-specific optimizations for Rivulet.Sql including COPY command integration for 10-100x faster bulk inserts.
Features
- COPY Command Integration: Ultra-high performance bulk inserts using COPY
- Multiple Formats: Binary, CSV, and text formats supported
- Parallel Operations: Process multiple batches in parallel
- Streaming Import: Efficient memory usage with streaming
- Custom Delimiters: Support for CSV with custom delimiters
- Header Support: Handle CSV files with headers
Installation
dotnet add package Rivulet.Sql.PostgreSql
Usage
Binary COPY (Fastest)
using Npgsql;
using Rivulet.Sql.PostgreSql;
var users = GetUsers(); // IEnumerable<User>
await users.BulkInsertUsingCopyAsync(
() => new NpgsqlConnection(connectionString),
"users",
columns: new[] { "id", "name", "email" },
mapToRow: user => new object?[] { user.Id, user.Name, user.Email },
options: new ParallelOptionsRivulet { MaxDegreeOfParallelism = 4 },
batchSize: 5000
);
CSV COPY
var csvLines = File.ReadLines("users.csv");
await csvLines.BulkInsertUsingCopyCsvAsync(
() => new NpgsqlConnection(connectionString),
"users",
columns: new[] { "id", "name", "email" },
options: new ParallelOptionsRivulet { MaxDegreeOfParallelism = 2 },
hasHeader: true,
delimiter: ','
);
Text COPY (Tab-Delimited)
var textLines = File.ReadLines("users.txt");
await textLines.BulkInsertUsingCopyTextAsync(
() => new NpgsqlConnection(connectionString),
"users",
columns: new[] { "id", "name", "email" },
options: new ParallelOptionsRivulet { MaxDegreeOfParallelism = 4 },
batchSize: 10000
);
Advanced: Custom Object Mapping
record Product(int Id, string Name, decimal Price, DateTime CreatedAt);
var products = GetProducts();
await products.BulkInsertUsingCopyAsync(
() => new NpgsqlConnection(connectionString),
"products",
columns: new[] { "id", "name", "price", "created_at" },
mapToRow: product => new object?[]
{
product.Id,
product.Name,
product.Price,
product.CreatedAt
},
options: new ParallelOptionsRivulet
{
MaxDegreeOfParallelism = 4,
ErrorMode = ErrorMode.CollectAndContinue
}
);
Performance
Comparison: Standard Insert vs COPY
| Method | Rows/sec | Time for 100k rows |
|---|---|---|
| Standard Batched Insert | ~1,000 | ~100 seconds |
| COPY Binary | ~50,000+ | ~2 seconds |
| Performance Gain | 50x faster | 50x faster |
Format Performance
| Format | Speed | Memory Usage | Use Case |
|---|---|---|---|
| Binary | Fastest | Low | Typed data, best performance |
| CSV | Fast | Low | CSV files, text data |
| Text | Fast | Low | Tab-delimited data |
Recommended Settings
- Batch Size: 5,000-10,000 rows per batch
- Max Parallelism: 2-4 for most workloads
- Format: Binary for best performance
When to Use
✅ Use Rivulet.Sql.PostgreSql when:
- Inserting 1,000+ rows
- Maximum performance is critical
- Using PostgreSQL exclusively
❌ Use base Rivulet.Sql when:
- Multi-database support needed
- Smaller datasets (<1,000 rows)
- Cross-platform compatibility required
Requirements
- .NET 8.0 or .NET 9.0
- PostgreSQL 10 or later
- Npgsql
License
MIT License - see LICENSE file for details
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Npgsql (>= 10.0.0)
- Rivulet.Sql (>= 1.3.0)
-
net9.0
- Npgsql (>= 10.0.0)
- Rivulet.Sql (>= 1.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.3.0 | 152 | 12/13/2025 |
| 1.3.0-beta | 409 | 12/8/2025 |
| 1.3.0-alpha | 287 | 12/8/2025 |