The Query EF Core Writes When You Ask for a Count
On EF Core 10.0.12, AsEnumerable() before Where().Count() sent a full-table SELECT instead of COUNT(*) and allocated 1056.36 KB against 49.53 KB at 1,000 rows.

Topics · 6 articles
On EF Core 10.0.12, AsEnumerable() before Where().Count() sent a full-table SELECT instead of COUNT(*) and allocated 1056.36 KB against 49.53 KB at 1,000 rows.

Assigning a struct to an interface allocated 0 bytes. Passing it across a call boundary allocated 24. A constrained generic allocated none, until its body asked for an object.

Removing UseRouting dropped per-request allocation by 2.29 KB in isolation — separated from authorization's share, routing itself costs about 24 bytes.

A thread pool queue held at two thousand work items read 1986 through one provider and -13 through the other, in the same second, in the same process.

Server GC finished 2.7 times faster and collected 17 times less often — and made the slowest request in the run 5 to 13 times slower. Both numbers are real.

An async method that never suspends allocates nothing. The same method, suspended once, allocates 160 bytes. The cost is not the keyword — it is the suspension.
