Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
YouTube Security VideosLinus Tech Tips: I Thought These Guys Made Cables(21.09.2026 um 19:15 Uhr)
Sicherheitslücken (CVE)GitHub Actions leaking secrets when Miri output is cached(21.09.2026 um 02:00 Uhr)
Sichere ProgrammierungBuilding a Polymarket TWAP Momentum Reversal Detector(21.09.2026 um 20:02 Uhr)
Sichere ProgrammierungWhy Does RAG Miss Information That's Clearly in the Document?(21.09.2026 um 20:04 Uhr)
YouTube Security VideosLinus Tech Tips: I Thought These Guys Made Cables(21.09.2026 um 19:15 Uhr)
Sicherheitslücken (CVE)GitHub Actions leaking secrets when Miri output is cached(21.09.2026 um 02:00 Uhr)
Sichere ProgrammierungBuilding a Polymarket TWAP Momentum Reversal Detector(21.09.2026 um 20:02 Uhr)
Sichere ProgrammierungWhy Does RAG Miss Information That's Clearly in the Document?(21.09.2026 um 20:04 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

NPoco vs UkrGuru.Sql: When Streaming Beats Buffering

When we talk about database performance in .NET, we often compare ORMs as if they were interchangeable. In practice, the API shape matters just as much as the implementation. In this post, I benchmark NPoco and UkrGuru.Sql using…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

When we talk about database performance in .NET, we often compare ORMs as if they were interchangeable. In practice, the API shape matters just as much as the implementation.



In this post, I benchmark NPoco and UkrGuru.Sql using BenchmarkDotNet, focusing on a very common task: reading a large table from SQL Server. The interesting part is not which library wins, but why the numbers differ so much.




TL;DR: Streaming rows with IAsyncEnumerable<T> is faster, allocates less, and scales better than loading everything into a list.










Test Scenario



The setup is intentionally simple and realistic.





  • Database: SQL Server


  • Table: Customers


  • Dataset: SampleStoreLarge (large enough to stress allocations)


  • Columns:


    • CustomerId

    • FullName

    • Email

    • CreatedAt








All benchmarks execute the same SQL:




SELECT CustomerId, FullName, Email, CreatedAt FROM Customers






No filters, no projections — just raw read performance.









Benchmark Code






using BenchmarkDotNet.Attributes;
using Microsoft.Data.SqlClient;
using NPoco;
using UkrGuru.Sql;

public class SqlBenchmark
{
private const string ConnectionString =
"Server=(local);Database=SampleStoreLarge;Trusted_Connection=True;TrustServerCertificate=True;";

private const string CommandText =
"SELECT CustomerId, FullName, Email, CreatedAt FROM Customers";

[Benchmark]
public async Task<int> NPoco_LoadList()
{
using var connection = new SqlConnection(ConnectionString);
await connection.OpenAsync();

using var db = new Database(connection);

var list = await db.FetchAsync<Customer>(CommandText);
return list.Count;
}

[Benchmark]
public async Task<int> UkrGuru_LoadList()
{
await using var connection = await DbHelper.CreateConnectionAsync(ConnectionString);

var list = await connection.ReadAsync<Customer>(CommandText);
return list.Count();
}

[Benchmark]
public async Task<int> UkrGuru_StreamRows()
{
int count = 0;

await using var command = await DbHelper.CreateCommandAsync(
CommandText,
connectionString: ConnectionString);

await foreach (var _ in command.ReadAsync<Customer>())
count++;

return count;
}
}






All benchmarks were run in Release mode with BenchmarkDotNet.









Results (Execution Time)
































Method Mean StdDev Median
NPoco_LoadList 8.23 ms 0.33 ms 8.22 ms
UkrGuru_LoadList 5.30 ms 0.57 ms 5.34 ms
UkrGuru_StreamRows 3.29 ms 0.14 ms 3.22 ms


At first glance, streaming is already ~2.5× faster than NPoco. But the real story starts when we look at memory.









Results (Memory & GC)




































Method Gen0 Gen1 Gen2 Allocated
NPoco_LoadList 367 258 109 4.39 MB
UkrGuru_LoadList 203 188 70 2.33 MB
UkrGuru_StreamRows 164 2.08 MB


This table explains almost everything.









What’s Actually Being Measured?






NPoco_LoadList




  • Uses FetchAsync<T>()

  • Fully materializes a List<Customer>

  • Allocates buffers and intermediate objects



✅ Idiomatic NPoco usage


❌ No streaming support



NPoco optimizes for developer productivity, not minimal allocations. That’s a valid trade‑off, but it shows up clearly in GC pressure.









UkrGuru_LoadList




  • Also builds a full list

  • Uses a leaner mapping pipeline

  • Roughly half the allocations of NPoco



✅ Same algorithm as NPoco


✅ Less overhead



This is a fair apple‑to‑apple comparison with NPoco’s approach.









UkrGuru_StreamRows




  • Uses IAsyncEnumerable<T>

  • Processes rows one at a time

  • No list allocation

  • No Gen2 collections



✅ True async streaming


✅ Lowest latency


✅ Most stable GC behavior



This is not a micro‑optimization — it’s a different execution model.









Why Streaming Wins



The biggest improvement is not raw speed — it’s memory behavior.




  • Fewer allocations

  • Almost no object promotion

  • No Gen2 collections



That matters a lot under real load: ASP.NET requests, background workers, message consumers, etc.




Streaming doesn’t just run faster — it scales better.










About Fairness



This benchmark is not trying to prove that one ORM is “better” than another.



It compares three distinct patterns:




  1. Buffered list materialization (NPoco)

  2. Buffered list materialization with fewer abstractions

  3. True async streaming



Comparing streaming to buffering is not “ORM vs ORM” — it’s algorithm vs algorithm.









When Should You Use Each?



Use NPoco when:




  • You want simple, expressive data access

  • Loading lists is acceptable

  • Developer time matters more than raw throughput



Use streaming (e.g. UkrGuru.Sql) when:




  • Result sets are large

  • Latency and GC pressure matter

  • You want full control over execution









Final Thoughts



Benchmarks don’t just measure libraries — they measure abstractions and APIs.



If your workload is dominated by large reads, switching from buffered lists to async streaming can cut both execution time and memory pressure dramatically.



Choose the tool that matches your data access pattern, not just the one you’re used to.

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten NPoco vs UkrGuru.Sql: When Streaming Beats Buffering

Thematisch verwandte Begriffe: NPoco, UkrGuruSql, When, Streaming · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-63416 | draw.io is a configurable diagramming and whiteboarding application. Pri…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick