Performance and benchmarks
On this page
TORM focuses on native database transport for batches, returning only the data a query needs, and reusing mapping and binding information. Imports, selected-column updates and continuous reads each have an API that avoids unnecessary per-entity work.
Representative results
These results come from the 2026-11-22 fixed CRUD workload short runs, compared with EF Core + BulkExtensions. Each measurement covers one complete operation. Allocation means cumulative managed allocation.
| Workload (10,000 rows each) | TORM time | Compared with EF Core + BulkExtensions |
|---|---|---|
| SQLite: insert | 26.67 ms | 24.5% less time, 80.6% less allocation |
| SQL Server: update all columns | 157.55 ms | 53.7% less time, 79.0% less allocation |
| SQL Server: selected-column update | 71.17 ms | 60.4% less time, 91.5% less allocation |
| MySQL: update all columns | 146.27 ms | 67.5% less time, 71.3% less allocation |
Across 20 database/workload combinations, TORM recorded a lower median time in 16 and lower managed allocation in 19. SQL Server conditional deletion and MySQL insertion, querying and conditional deletion took longer.
How bulk writes reduce work
BulkCopy<T>() chooses its transport through the provider. A shared API does not imply identical SQL on every database.
| Provider | Implementation | Work avoided |
|---|---|---|
| SQL Server | SqlBulkCopy with an entity data reader | No full-batch DataTable copy; updates transfer through a temporary table and use a set-based update |
| PostgreSQL | Npgsql binary COPY; temporary table and UPDATE FROM for updates | Fixed column ordering and binary values reduce individual commands and text parameter construction |
| MySQL | MySqlBulkCopy fed by an entity reader | Avoids intermediate table objects; updates load a temporary table before a joined update |
| SQLite | Provider-specific insertion, update and save implementations | Reuses statements and parameters within a transaction; eligible batches reuse a native prepared statement and binding plan |
SQLite’s native path has eligibility requirements, including a known batch count. Unknown-size sequences and unsupported commands retain the driver path. Bulk updates on SQL Server, PostgreSQL and MySQL also pay for temporary table creation, transfer and cleanup, so compare ordinary range writes for small batches.
Entity names, columns and keys are cached by type. Reader-ordinal/property bindings are reused across rows; first access still has initialization costs. See AOT and source generation for compile-time provider registration.
Choose the API that does less work
| Task | Entry point | Benefit and boundary |
|---|---|---|
| Insert a collection | InsertableRange; compare BulkInsertAsync at larger sizes | Let the provider process the batch and amortize command construction and round trips |
| Set every matching row to the same value | Updatable<T>().SetColumns(...).Where(...) | Execute a conditional database update without first loading and returning entities |
| Update different values per row | UpdatableRange or BulkUpdateAsync, with UpdateColumns | Transfer only changed columns; index match columns appropriately |
| Insert or update on a known conflict key | Savable entity or collection overloads | Provider-native upsert avoids an application-side existence query; a unique constraint is still required |
| Return only displayed fields | Select + ToListAsync | SQL projection reduces transferred data and conversion work |
| Check existence or calculate statistics | AnyAsync, CountAsync, aggregate APIs | Return a scalar instead of materializing entity collections |
| Fetch successive batches without totals | ToCursorPageAsync | Resume by internal table/key order, reading one extra row for continuation and skipping a count query |
| Export or process a large result | ToAsyncEnumerable | Avoid a full result list; the reader and connection remain occupied while enumerating |
Cursor paging requires full entities and internal ordering. It cannot be combined with custom ordering, projection or Skip / Take. Use ordinary paging for business-field sorting and total page counts. Do not execute another command on the same client while consuming its stream.
Working examples: queries, projection and paging, bulk writes, and transactions and connection lifetime.
Full comparison across four databases
Every pair is TORM / EF Core + BulkExtensions. Queries start with 50,000 rows and return 25,000; other workloads operate on 10,000 rows. Selected-column updates change only Age.
SQLite
| Workload | Time, ms | Managed allocation, KiB |
|---|---|---|
| Bulk insert | 26.67 / 35.31 | 2,819.87 / 14,504.62 |
| Bulk update, all columns | 32.75 / 43.19 | 2,820.64 / 14,506.66 |
| Bulk update, selected column | 18.16 / 26.41 | 1,492.14 / 4,491.22 |
| Query | 43.62 / 52.50 | 3,446.26 / 5,006.62 |
| Conditional delete | 5.05 / 6.58 | 4.40 / 7.59 |
SQL Server
| Workload | Time, ms | Managed allocation, KiB |
|---|---|---|
| Bulk insert | 126.59 / 146.09 | 2,132.03 / 9,818.04 |
| Bulk update, all columns | 157.55 / 340.41 | 2,066.47 / 9,854.93 |
| Bulk update, selected column | 71.17 / 179.61 | 497.19 / 5,852.71 |
| Query | 23.59 / 26.22 | 5,496.20 / 5,525.85 |
| Conditional delete | 15.90 / 13.83 | 6.52 / 9.19 |
PostgreSQL
| Workload | Time, ms | Managed allocation, KiB |
|---|---|---|
| Bulk insert | 71.01 / 82.03 | 1,568.78 / 4,616.45 |
| Bulk update, all columns | 113.78 / 121.64 | 1,575.93 / 4,647.15 |
| Bulk update, selected column | 92.30 / 98.45 | 479.20 / 1,180.27 |
| Query | 22.78 / 23.21 | 3,461.31 / 3,473.95 |
| Conditional delete | 7.86 / 8.55 | 5.32 / 8.95 |
MySQL
| Workload | Time, ms | Managed allocation, KiB |
|---|---|---|
| Bulk insert | 100.70 / 95.12 | 3,205.24 / 11,160.00 |
| Bulk update, all columns | 146.27 / 450.54 | 3,216.87 / 11,197.05 |
| Bulk update, selected column | 135.23 / 327.93 | 495.59 / 7,494.01 |
| Query | 35.65 / 33.57 | 3,462.54 / 3,460.14 |
| Conditional delete | 35.19 / 31.68 | 6.98 / 11.66 |
Environment, statistics and sources
| Item | Setting |
|---|---|
| OS and CPU | Windows 10, AMD Ryzen 9 5900X |
| Runtime | Release, .NET 10.0.15, DOTNET_TieredCompilation=0 |
| Databases | SQLite WAL + FULL; Docker SQL Server 2022, PostgreSQL 17 and MySQL 8.4 |
| Comparison | EF Core 10.0.15; BulkExtensions built from corresponding 10.0.2 upstream source |
| Comparison APIs | BulkExtensions for bulk writes, no-tracking compiled queries, ExecuteDeleteAsync for deletes |
| Samples | Two independent processes, two warmups and three recorded windows each; ORM order alternates |
| Statistics | Six-sample median of time and allocation normalized per operation; six queries per window, one invocation for other workloads |
| Timing boundary | Data preparation, forced GC and field-by-field result checks are outside timing |
These historical short runs describe a particular data shape, driver and machine. Managed allocation is the cumulative amount allocated during an operation, not peak memory or the live heap. Consult the original ranges when timings are close.
Source: TORM benchmark project README , which also records CPU, GC, time ranges and SQLite comparisons with SqlSugar, FreeSql and EF Core. The four-ORM SQLite comparison uses a separate host and a different BulkExtensions version; its results are not combined with this table.
Tune your own workload
Start by reducing work per operation: filter and project in SQL, restrict updated columns, and enumerate batch input once. Then compare ordinary range writes with BulkCopy while varying batch size. Record total time, allocation, database CPU and lock waits. Larger batches can increase parameter volume, temporary-table costs, transaction logs and lock duration.
The standalone TORM repository contains benchmark/TORM.Benchmark. Its entry point supports --list flat, --filter and --smoke; smoke mode validates results only. Save source and dependency versions, database settings, indexes and result counts with each measurement, and verify the data. Execution plans and I/O often determine the final bottleneck; lower client allocation does not always produce lower request latency.