Skip to Content
TORMPerformance and benchmarks

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 timeCompared with EF Core + BulkExtensions
SQLite: insert26.67 ms24.5% less time, 80.6% less allocation
SQL Server: update all columns157.55 ms53.7% less time, 79.0% less allocation
SQL Server: selected-column update71.17 ms60.4% less time, 91.5% less allocation
MySQL: update all columns146.27 ms67.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.

ProviderImplementationWork avoided
SQL ServerSqlBulkCopy with an entity data readerNo full-batch DataTable copy; updates transfer through a temporary table and use a set-based update
PostgreSQLNpgsql binary COPY; temporary table and UPDATE FROM for updatesFixed column ordering and binary values reduce individual commands and text parameter construction
MySQLMySqlBulkCopy fed by an entity readerAvoids intermediate table objects; updates load a temporary table before a joined update
SQLiteProvider-specific insertion, update and save implementationsReuses 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

TaskEntry pointBenefit and boundary
Insert a collectionInsertableRange; compare BulkInsertAsync at larger sizesLet the provider process the batch and amortize command construction and round trips
Set every matching row to the same valueUpdatable<T>().SetColumns(...).Where(...)Execute a conditional database update without first loading and returning entities
Update different values per rowUpdatableRange or BulkUpdateAsync, with UpdateColumnsTransfer only changed columns; index match columns appropriately
Insert or update on a known conflict keySavable entity or collection overloadsProvider-native upsert avoids an application-side existence query; a unique constraint is still required
Return only displayed fieldsSelect + ToListAsyncSQL projection reduces transferred data and conversion work
Check existence or calculate statisticsAnyAsync, CountAsync, aggregate APIsReturn a scalar instead of materializing entity collections
Fetch successive batches without totalsToCursorPageAsyncResume by internal table/key order, reading one extra row for continuation and skipping a count query
Export or process a large resultToAsyncEnumerableAvoid 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

WorkloadTime, msManaged allocation, KiB
Bulk insert26.67 / 35.312,819.87 / 14,504.62
Bulk update, all columns32.75 / 43.192,820.64 / 14,506.66
Bulk update, selected column18.16 / 26.411,492.14 / 4,491.22
Query43.62 / 52.503,446.26 / 5,006.62
Conditional delete5.05 / 6.584.40 / 7.59

SQL Server

WorkloadTime, msManaged allocation, KiB
Bulk insert126.59 / 146.092,132.03 / 9,818.04
Bulk update, all columns157.55 / 340.412,066.47 / 9,854.93
Bulk update, selected column71.17 / 179.61497.19 / 5,852.71
Query23.59 / 26.225,496.20 / 5,525.85
Conditional delete15.90 / 13.836.52 / 9.19

PostgreSQL

WorkloadTime, msManaged allocation, KiB
Bulk insert71.01 / 82.031,568.78 / 4,616.45
Bulk update, all columns113.78 / 121.641,575.93 / 4,647.15
Bulk update, selected column92.30 / 98.45479.20 / 1,180.27
Query22.78 / 23.213,461.31 / 3,473.95
Conditional delete7.86 / 8.555.32 / 8.95

MySQL

WorkloadTime, msManaged allocation, KiB
Bulk insert100.70 / 95.123,205.24 / 11,160.00
Bulk update, all columns146.27 / 450.543,216.87 / 11,197.05
Bulk update, selected column135.23 / 327.93495.59 / 7,494.01
Query35.65 / 33.573,462.54 / 3,460.14
Conditional delete35.19 / 31.686.98 / 11.66

Environment, statistics and sources

ItemSetting
OS and CPUWindows 10, AMD Ryzen 9 5900X
RuntimeRelease, .NET 10.0.15, DOTNET_TieredCompilation=0
DatabasesSQLite WAL + FULL; Docker SQL Server 2022, PostgreSQL 17 and MySQL 8.4
ComparisonEF Core 10.0.15; BulkExtensions built from corresponding 10.0.2 upstream source
Comparison APIsBulkExtensions for bulk writes, no-tracking compiled queries, ExecuteDeleteAsync for deletes
SamplesTwo independent processes, two warmups and three recorded windows each; ORM order alternates
StatisticsSix-sample median of time and allocation normalized per operation; six queries per window, one invocation for other workloads
Timing boundaryData 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.