PgBulkOps 0.1.0
dotnet add package PgBulkOps --version 0.1.0
NuGet\Install-Package PgBulkOps -Version 0.1.0
<PackageReference Include="PgBulkOps" Version="0.1.0" />
<PackageVersion Include="PgBulkOps" Version="0.1.0" />
<PackageReference Include="PgBulkOps" />
paket add PgBulkOps --version 0.1.0
#r "nuget: PgBulkOps, 0.1.0"
#:package PgBulkOps@0.1.0
#addin nuget:?package=PgBulkOps&version=0.1.0
#tool nuget:?package=PgBulkOps&version=0.1.0
PgBulkOps
PgBulkOps is a high-performance .NET library for PostgreSQL bulk operations. It provides ultra-fast bulk insert and bulk update methods using PostgreSQLβs native binary COPY protocol.
Built on top of Npgsql, PgBulkOps can handle millions of rows in just a few seconds.
β¨ Features Bulk insert with PostgreSQL binary COPY Bulk update using COPY + temporary table + UPDATE ... FROM join Optional PascalCase β snake_case column name conversion Progress callback with configurable batch size Fully async/await compatible π¦ Installation dotnet add package PgBulkOps
β¨ Quick Start
Entity Definition
public class User { public long Id { get; set; } public string Name { get; set; } = default!; public string Email { get; set; } = default!; public int Age { get; set; } public bool IsActive { get; set; } public decimal Balance { get; set; } public DateTime CreatedAt { get; set; } public DateTime? UpdatedAt { get; set; } public string Country { get; set; } = default!; public DateTime? LastLogin { get; set; } }
Bulk Insert Example
using Npgsql; using PgBulkOps;
await using var conn = new NpgsqlConnection("Host=localhost;Database=test;Username=postgres;Password=secret");
var rnd = new Random(); var users = Enumerable.Range(1, 100_000) .Select(i β new User { Id = i, Name = $"User{i}", Email = $"user{i}@example.com", Age = rnd.Next(18, 70), IsActive = i % 2 == 0, Balance = (decimal)(rnd.NextDouble() * 10000), CreatedAt = DateTime.UtcNow, Country = i % 2 == 0 ? "TR" : "US", LastLogin = DateTime.UtcNow.AddMinutes(-rnd.Next(1, 10000)) });
await conn.BulkInsertAsync(users, "Users", opts β { opts.BatchSize = 50_000; opts.UseSnakeCase = true; opts.OnProgress = p β Console.WriteLine($"Inserted {p.Rows} rows..."); });
Bulk Update Example
// Update existing users foreach (var user in users) user.Name = user.Name + "_updated";
await conn.BulkUpdateAsync(users, "Users", "Id", opts β { opts.BatchSize = 50_000; opts.UseSnakeCase = true; opts.OnProgress = p β Console.WriteLine($"Updated {p.Rows} rows..."); });
β‘ Performance Typical throughput (depending on hardware, WAL, and indexes):
Bulk Insert β 300kβ400k rows/sec
Bulk Update β 30kβ80k rows/sec
In benchmarks, inserting 1,000,000 rows often completes in ~3 seconds.
β οΈ Notes PostgreSQL user must have INSERT/UPDATE privileges.
PascalCase properties map automatically to snake_case columns if UseSnakeCase = true.
For massive loads, consider disabling indexes and triggers temporarily.
π License MIT License β maintained by Onventus.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
-
net9.0
- Npgsql (>= 9.0.4)
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 |
|---|---|---|
| 0.1.0 | 201 | 10/5/2025 |