<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Viktor Ponamarev on Medium]]></title>
        <description><![CDATA[Stories by Viktor Ponamarev on Medium]]></description>
        <link>https://medium.com/@vikpoca?source=rss-043b7986232b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*VFo0BfB-Xt4ihBLYfWwKGg.png</url>
            <title>Stories by Viktor Ponamarev on Medium</title>
            <link>https://medium.com/@vikpoca?source=rss-043b7986232b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 22:09:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vikpoca/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[60 Fields in Job Application. Standard Rejection Email. Now It Is Personal]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@vikpoca/60-fields-in-job-application-standard-rejection-email-now-it-is-personal-c5ce1e27658f?source=rss-043b7986232b------2"><img src="https://cdn-images-1.medium.com/max/1672/1*6-GORlV0S6N6Ps2gyIR5_A.png" width="1672"></a></p><p class="medium-feed-snippet">A guy decides to automate the whole job application process with Claude to not feel offended.</p><p class="medium-feed-link"><a href="https://medium.com/@vikpoca/60-fields-in-job-application-standard-rejection-email-now-it-is-personal-c5ce1e27658f?source=rss-043b7986232b------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@vikpoca/60-fields-in-job-application-standard-rejection-email-now-it-is-personal-c5ce1e27658f?source=rss-043b7986232b------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5ce1e27658f</guid>
            <category><![CDATA[claude-code]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[job-search]]></category>
            <category><![CDATA[hiring]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Viktor Ponamarev]]></dc:creator>
            <pubDate>Wed, 28 Oct 2026 21:05:45 GMT</pubDate>
            <atom:updated>2026-10-29T00:07:56.875Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[440% LLM Performance Boost with Qwen 3.8 Flash Next]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@vikpoca/440-llm-performance-boost-with-qwen-3-8-flash-next-6acc9aae2743?source=rss-043b7986232b------2"><img src="https://cdn-images-1.medium.com/max/2048/1*UgEYLrw0tFyfqS_nIXD_Zg.jpeg" width="2048"></a></p><p class="medium-feed-snippet">The 125B Model That Uses 6B at a Time &#x2014; and Brought My RTX 3090s to Their Knees</p><p class="medium-feed-link"><a href="https://medium.com/@vikpoca/440-llm-performance-boost-with-qwen-3-8-flash-next-6acc9aae2743?source=rss-043b7986232b------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@vikpoca/440-llm-performance-boost-with-qwen-3-8-flash-next-6acc9aae2743?source=rss-043b7986232b------2</link>
            <guid isPermaLink="false">https://medium.com/p/6acc9aae2743</guid>
            <category><![CDATA[local-llm]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[llama-cpp]]></category>
            <dc:creator><![CDATA[Viktor Ponamarev]]></dc:creator>
            <pubDate>Fri, 23 Oct 2026 22:26:33 GMT</pubDate>
            <atom:updated>2026-10-23T22:26:33.504Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[SOLID Still Matters.]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@vikpoca/solid-still-matters-aed64eab48c8?source=rss-043b7986232b------2"><img src="https://cdn-images-1.medium.com/max/1672/1*NxmU0kuysaYZ1Jk8chzsKA.png" width="1672"></a></p><p class="medium-feed-snippet">Just Not the Way It Used To.</p><p class="medium-feed-link"><a href="https://medium.com/@vikpoca/solid-still-matters-aed64eab48c8?source=rss-043b7986232b------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@vikpoca/solid-still-matters-aed64eab48c8?source=rss-043b7986232b------2</link>
            <guid isPermaLink="false">https://medium.com/p/aed64eab48c8</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[solid-principles]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[design-patterns]]></category>
            <dc:creator><![CDATA[Viktor Ponamarev]]></dc:creator>
            <pubDate>Mon, 31 Aug 2026 23:11:50 GMT</pubDate>
            <atom:updated>2026-08-31T23:11:50.316Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Simple LeetCode Problem Turned Into a Follow-Up Nightmare in an Interview]]></title>
            <link>https://medium.com/@vikpoca/simple-leetcode-problem-turned-into-a-follow-up-nightmare-in-an-interview-548aadab6b77?source=rss-043b7986232b------2</link>
            <guid isPermaLink="false">https://medium.com/p/548aadab6b77</guid>
            <category><![CDATA[leetcode]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[design]]></category>
            <dc:creator><![CDATA[Viktor Ponamarev]]></dc:creator>
            <pubDate>Fri, 28 Aug 2026 20:24:07 GMT</pubDate>
            <atom:updated>2026-08-28T22:17:34.493Z</atom:updated>
            <content:encoded><![CDATA[<p>I was once asked to merge two sorted arrays in an interview.</p><p>The question was close to <a href="https://leetcode.com/problems/merge-sorted-array/">LeetCode 88</a>. The first array had enough empty space at the end to hold the second one. Both arrays were already sorted. The result had to end up in the first array.</p><p>For example:</p><pre>nums1 = [1, 2, 3, 0, 0, 0]<br>nums2 = [2, 5, 6]<br><br>result = [1, 2, 2, 3, 5, 6]</pre><p>LeetCode labels this problem Easy. That label was accurate for the first few minutes of the interview.</p><h3>The answer that finishes the LeetCode problem</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CTxwsRyM8f0c4V1amxqWBw.png" /></figure><p>The shortest working solution copies nums2 into the unused part of nums1 and sorts the whole array. It produces the correct result in O((m + n) log(m + n)) time, but it throws away the most useful fact in the question: both inputs are already sorted.</p><p>A linear solution compares the current elements of the two arrays and moves the smaller one into the result. Starting at the front requires a temporary array, though. Writing into nums1[0] may destroy a value that has not been read yet.</p><p>The empty space is at the other end, so the standard in-place solution works backward:</p><pre>public static void Merge(int[] nums1, int m, int[] nums2, int n)<br>{<br>    var left = m - 1;<br>    var right = n - 1;<br>    var write = m + n - 1;<br><br>    while (right &gt;= 0)<br>    {<br>        if (left &gt;= 0 &amp;&amp; nums1[left] &gt; nums2[right])<br>        {<br>            nums1[write--] = nums1[left--];<br>        }<br>        else<br>        {<br>            nums1[write--] = nums2[right--];<br>        }<br>    }<br>}</pre><p>Each step places the largest remaining value into a position that is safe to overwrite. If nums2 becomes empty first, the unused values from nums1 are already where they belong. The loop therefore needs to check only right.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B1RVbceGgiGZQlM9ZxDu3g.png" /></figure><p>Time complexity is O(m + n). Additional space is O(1).</p><p>On LeetCode, this earns an accepted submission. The interviewer changed one word in the question.</p><h3>Then two arrays became N arrays</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4ACQWvytLDqH0OKdCWJLKA.png" /></figure><p>“What if there are N sorted arrays?”</p><p>Two pointers no longer cover the inputs. We could merge the first two arrays, merge that result with the third, and continue. With k arrays of similar size, the early values get copied again for every later array. The total cost grows to O(Tk), where T is the number of values across all arrays.</p><p>A balanced tree of pairwise merges reduces that to O(T log k). A min-heap gives the same bound and fits streaming input better.</p><p>The heap holds one candidate from each array. Remove the smallest candidate, emit it, and insert the next value from the same array. Its size never exceeds k.</p><pre>public static IEnumerable&lt;int&gt; MergeMany(IReadOnlyList&lt;int[]&gt; arrays)<br>{<br>    var queue = new PriorityQueue&lt;<br>        (int Array, int Index),<br>        (int Value, int Array)&gt;();<br><br>    for (var array = 0; array &lt; arrays.Count; array++)<br>    {<br>        if (arrays[array].Length &gt; 0)<br>        {<br>            queue.Enqueue(<br>                (array, 0),<br>                (arrays[array][0], array));<br>        }<br>    }<br><br>    while (queue.TryDequeue(out var cursor, out var priority))<br>    {<br>        yield return priority.Value;<br><br>        var next = cursor.Index + 1;<br>        if (next &lt; arrays[cursor.Array].Length)<br>        {<br>            queue.Enqueue(<br>                (cursor.Array, next),<br>                (arrays[cursor.Array][next], cursor.Array));<br>        }<br>    }<br>}</pre><p>.NET’s <a href="https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.priorityqueue-2">PriorityQueue&lt;TElement, TPriority&gt;</a> removes the item with the lowest priority. It does not promise FIFO ordering when priorities are equal, so the priority above contains both the value and the source array index. That second field gives equal values a deterministic order.</p><p>The merge now takes O(T log k) time and keeps O(k) heap entries. The output is lazy because of yield return.</p><p>The heap answered the N-array follow-up. The next question removed the assumption hidden inside the word <em>array</em>.</p><h3>The arrays no longer fit in RAM</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nV--K145juDlg4tbhi6zBQ.png" /></figure><p>“What if the arrays are so large that they do not fit in memory?”</p><p>int[] is now the wrong interface. The heap needs only the current value from each sorted source and a way to ask that source for its next value.</p><p>An input can be a file reader instead of an array. Give each file a read buffer, read one value from every buffer into the heap, and write each winner to an output buffer. When a buffer runs empty, refill it from disk. With k inputs and buffers of size B, working memory is O(kB) plus the O(k) heap. The complete input and output never need to occupy RAM.</p><p>For two sorted files, even the heap disappears. Two readers and one writer are enough. The merge still takes linear time, but O(T) now hides the operation we pay for: the entire dataset must be read and written.</p><p>This answer depends on the files already being sorted. If the inputs are arbitrary, we have a different problem: external merge sort.</p><p>External merge sort reads a memory-sized chunk, sorts it in RAM, and writes it as a temporary sorted run. It repeats that process until the original input has been converted into runs. The second phase merges those runs with the same heap algorithm we just used for N arrays.</p><p>The original LeetCode operation returns in the second phase. A large sort manufactures a collection of smaller sorted inputs and hands them back to the merge.</p><h3>Big O starts hiding the bill</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1jO41gNNNw3j0iYt3VOULw.png" /></figure><p>Suppose the first phase creates 10,000 sorted runs. Opening all of them and assigning a useful buffer to every file may exceed both the memory budget and the operating system’s file descriptor limit.</p><p>The merge needs a bounded fan-in. If we merge 100 runs at a time, 10,000 runs become 100 larger runs after the first pass and one final run after the second. If only ten inputs can be merged at once, the same job needs four passes.</p><p>That difference is expensive. For a 100 TB dataset, every merge pass reads about 100 TB and writes about 100 TB. Two passes move roughly 400 TB during the merge phase. Four passes move roughly 800 TB. The comparison count still matters, but it will not explain that runtime.</p><p>Production tools expose these physical limits directly. GNU sort, for example, has separate options for the memory buffer, temporary directory, merging presorted files, and the maximum number of inputs merged at once. Its <a href="https://www.gnu.org/software/coreutils/manual/html_node/sort-invocation.html">--batch-size</a> limit is constrained by the number of file descriptors the process can open.</p><p>At this point an interview answer needs more than an algorithm name. It needs a record format, buffer sizes, temporary-file placement, cleanup rules, and a restart strategy. A process that fails after writing 93 TB should not restart by erasing every completed run.</p><h3>One machine no longer has enough disk</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ITi1_KZBHOVn60RjVeNkwg.png" /></figure><p>The interview I remember had already moved far beyond the Easy problem. But the thought experiment has another step:</p><p>“What if the data does not fit on the disks of one machine?”</p><p>There can be no final nums1. The result must stay split across machines or distributed storage. Those pieces also need a global order. Hashing values across workers spreads the load, but partition 0 would contain unrelated values from the entire key space. Concatenating the partitions would not produce a sorted result.</p><p>Distributed sorting uses range partitions. Choose p - 1 splitter keys for p workers. One worker receives values below the first splitter, another receives the next range, and so on. Each worker performs a local k-way merge and writes one output partition. A small manifest records the partitions in order.</p><p>The global correctness condition is simple to state. Every partition must be sorted internally, and the largest value in partition i must be less than or equal to the smallest value in partition i + 1. Choosing boundaries that also balance the workers is harder.</p><p>Good splitters require some knowledge of the data distribution. Equal-width numeric ranges work badly when most values sit in a narrow interval. Sampling can estimate quantiles, but a sample can miss a dense region.</p><p>Hadoop’s <a href="https://hadoop.apache.org/docs/current/api/org/apache/hadoop/examples/terasort/package-summary.html">TeraSort</a> is a concrete version of this design. It samples keys, chooses N - 1 boundaries, and sends each key range to a reducer. Hadoop&#39;s documented 2008 run sampled 100,000 keys, yet reducer outputs ranged from 337 MB to 872 MB. The output order was correct; the slowest worker received more than twice the data of the smallest one.</p><p>Duplicate values make the boundary problem sharper. If 30 percent of the records have the same key, a half-open range sends that entire group to one worker. For a pure sort, we can extend the ordering key to (value, sourceId, offset). Equal values can then be split while retaining a deterministic total order. If all equal keys must stay together for later aggregation, the large partition is part of the requirement and needs separate handling.</p><p>Our inputs have one advantage over a generic distributed sort: they are already sorted. Each source can find or scan to the splitter boundaries and expose contiguous ranges. Workers merge those ranges without sorting them again. Data may still cross the network, but the local work remains the same operation used in the first answer.</p><h3>Then failures become part of correctness</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yZDdFYjWxgmMRrPX_Mpw1A.png" /></figure><p>A three-pointer LeetCode method either returns or throws. A distributed merge may finish 999 partitions while one worker disappears.</p><p>A practical implementation writes every partition to an attempt-specific location. After a worker finishes, the coordinator records that partition as complete. A retry reads the same immutable inputs and produces the same ordered range. The final manifest is published only after every partition has succeeded.</p><p>Validation must also be distributed. Each worker verifies the order inside its partition and reports its first value, last value, record count, and checksum. A coordinator checks adjacent boundaries and reconciles the counts. Hadoop includes a separate TeraValidate job that follows this pattern: it checks order inside each output file, then compares the boundary keys between neighboring files.</p><p>The original <a href="https://research.google/pubs/mapreduce-simplified-data-processing-on-large-clusters/">MapReduce paper</a> focuses on the machinery now surrounding the merge: partitioning, scheduling, network transfer, failed workers, and retries around a comparatively small user function.</p><p>By now, the merge loop is the easy part again. Most of the code exists to make sure that every worker agrees about which values it owns and that completed work survives a failure.</p><h3>The question stayed the same</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RhGEht3bs3N2tfEAFYLVHg.png" /></figure><p>The first answer was concerned with overwriting an integer in nums1. The last answer has to prevent two machines from publishing overlapping key ranges.</p><p>Each follow-up changed the expensive operation. In memory, we count comparisons and allocations. With files, we count full passes over the data. Across machines, we count transferred bytes and wait for the slowest partition. Once failures enter the model, retry cost and deterministic output join the calculation.</p><p>Every version repeats the same selection rule: take the smallest available value and advance that input. In the first method, <em>available</em> means an array access. Later it means a buffered read or a record assigned to the current worker.</p><p>LeetCode 88 is Easy because its constraints have already settled the storage questions. The inputs fit in RAM. Random access is cheap. The output fits in one array. The judge never asks how to recover a failed worker.</p><p>Remove those constraints one at a time, and the accepted solution grows from three pointers into an external sort and then a distributed storage job. Inside each worker, somewhere beneath the buffering, partition manifests, and retry logic, the same merge loop is still running.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=548aadab6b77" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Perfectionism. Why Enterprise Developers Fail at Side Projects.]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@vikpoca/perfectionism-why-enterprise-developers-fail-at-side-projects-d42f40bd13d0?source=rss-043b7986232b------2"><img src="https://cdn-images-1.medium.com/max/1672/1*Rh1ob6U7weRrT9pwKw4CHg.png" width="1672"></a></p><p class="medium-feed-snippet">AI makes it worse.</p><p class="medium-feed-link"><a href="https://medium.com/@vikpoca/perfectionism-why-enterprise-developers-fail-at-side-projects-d42f40bd13d0?source=rss-043b7986232b------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@vikpoca/perfectionism-why-enterprise-developers-fail-at-side-projects-d42f40bd13d0?source=rss-043b7986232b------2</link>
            <guid isPermaLink="false">https://medium.com/p/d42f40bd13d0</guid>
            <category><![CDATA[vibe-coding]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[enterprise-software]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Viktor Ponamarev]]></dc:creator>
            <pubDate>Fri, 21 Aug 2026 08:16:01 GMT</pubDate>
            <atom:updated>2026-08-21T08:16:01.096Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Why C# Developers Are Underrepresented in AI Startups]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@vikpoca/why-c-developers-are-underrepresented-in-ai-startups-f3152368c262?source=rss-043b7986232b------2"><img src="https://cdn-images-1.medium.com/max/1672/1*W-ZfcGzUlI9N134_-2YcKQ.png" width="1672"></a></p><p class="medium-feed-snippet">C# was not rejected by AI. It was absent from the room where AI acquired its habits.</p><p class="medium-feed-link"><a href="https://medium.com/@vikpoca/why-c-developers-are-underrepresented-in-ai-startups-f3152368c262?source=rss-043b7986232b------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@vikpoca/why-c-developers-are-underrepresented-in-ai-startups-f3152368c262?source=rss-043b7986232b------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3152368c262</guid>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Viktor Ponamarev]]></dc:creator>
            <pubDate>Tue, 18 Aug 2026 23:40:02 GMT</pubDate>
            <atom:updated>2026-08-18T23:40:02.266Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[3 Lines of SQL. Passed Review. Money Lost.]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@vikpoca/3-lines-of-sql-passed-review-money-lost-bed604f2a66c?source=rss-043b7986232b------2"><img src="https://cdn-images-1.medium.com/max/1672/1*h3I82a8PbYv5dLFy4DYGLw.png" width="1672"></a></p><p class="medium-feed-snippet">Junior sees nothing wrong. Senior sees 4 problems.</p><p class="medium-feed-link"><a href="https://medium.com/@vikpoca/3-lines-of-sql-passed-review-money-lost-bed604f2a66c?source=rss-043b7986232b------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@vikpoca/3-lines-of-sql-passed-review-money-lost-bed604f2a66c?source=rss-043b7986232b------2</link>
            <guid isPermaLink="false">https://medium.com/p/bed604f2a66c</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Viktor Ponamarev]]></dc:creator>
            <pubDate>Tue, 18 Aug 2026 07:16:00 GMT</pubDate>
            <atom:updated>2026-08-18T15:20:32.864Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[EF Core Tracking Is Silently Wasting Your Memory]]></title>
            <link>https://medium.com/@vikpoca/ef-core-tracking-is-silently-wasting-your-memory-236249ef9635?source=rss-043b7986232b------2</link>
            <guid isPermaLink="false">https://medium.com/p/236249ef9635</guid>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Viktor Ponamarev]]></dc:creator>
            <pubDate>Sat, 15 Aug 2026 06:06:01 GMT</pubDate>
            <atom:updated>2026-08-15T06:06:01.538Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R9vk1EmRl0ZHNLLxk6PdUw.png" /></figure><p>Your endpoint returns 50 order summaries. The query allocates objects for every matching order.</p><p>The response looks bounded, so the memory usage is easy to blame on serialization, caching, or the usual background noise. But the limit is applied after ToListAsync. By then, EF Core has already fetched the complete result, materialized an entity graph, and added its tracking state to the DbContext.</p><p>AsNoTracking reduces part of that cost. It doesn&#39;t reduce the number of rows, make a wide entity query narrow, or stop EF Core from creating the entities you asked for.</p><p>For a read-only API, the more complete fix is to keep the query in SQL, bound it there, and project directly to the response model before the first materialization call.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E_s_Xduqetd9DA0wz9j-Ew.png" /></figure><h3>The 50 rows aren’t the problem</h3><p>This version is completely believable:</p><pre>var orders = await db.Orders<br>    .Include(o =&gt; o.Customer)<br>    .Where(o =&gt; o.Status == status)<br>    .ToListAsync(cancellationToken);<br><br>return orders<br>    .OrderByDescending(o =&gt; o.CreatedUtc)<br>    .ThenByDescending(o =&gt; o.Id)<br>    .Take(pageSize)<br>    .Select(o =&gt; new OrderListItem(<br>        o.Id,<br>        o.Number,<br>        o.CreatedUtc,<br>        o.Customer.Name,<br>        o.Total))<br>    .ToList();</pre><p>The endpoint returns at most pageSize items. The database query doesn&#39;t.</p><p>ToListAsync is the boundary. Everything before it is an IQueryable expression that the relational provider can translate. Everything after it runs over an in-memory List&lt;Order&gt;.</p><p>That means the database sends every order matching status, together with the included customer data. EF Core materializes those keyed entities and tracks them by default. Only then does application code sort the complete list, keep 50 orders, and allocate a second list containing DTOs.</p><p>The hidden state is easy to expose:</p><pre>var trackedEntries = db.ChangeTracker.Entries().Count();</pre><p>Read that value immediately after the first ToListAsync. It will include the materialized orders and the distinct customers resolved into the graph. Take(pageSize) changes none of that work. It limits only the second list.</p><h3>What tracking keeps in memory</h3><p>A tracking query does more than construct CLR objects.</p><p>EF Core’s state manager maintains an identity lookup for tracked entities. When another row contains the same entity key, EF Core checks that lookup and reuses the existing instance. This is identity resolution, and it is what keeps two orders for the same customer pointing at one Customer object. Microsoft&#39;s <a href="https://learn.microsoft.com/en-us/ef/core/performance/efficient-querying">efficient-querying documentation</a> describes this as an internal dictionary of tracked instances.</p><p>EF Core also ordinarily stores an original-value snapshot for each tracked entity. Later, SaveChanges can compare current values with those snapshots and determine which properties changed. Navigation fix-up connects relationships as entities enter the tracker.</p><p>Those features are valuable in a read-modify-save unit of work. On a response-only query, the identity lookups, tracking entries, snapshots, and fix-up work may exist only to be discarded.</p><p>With a correctly scoped request DbContext, that is usually allocation and peak-live-memory pressure, not a permanent leak. Disposal releases the context and its tracking state for collection. Under concurrency, however, many overlapping requests can hold those graphs at the same time and push up allocation rate, GC frequency, managed heap size, and working set.</p><p>A long-lived context changes the failure mode. <a href="https://learn.microsoft.com/en-us/ef/core/change-tracking/">Tracked entities remain attached</a> until they are detached, the tracker is cleared, or the context is disposed. Reusing one context across operations can therefore retain more and more application state. ChangeTracker.Clear() exists, but it isn&#39;t a routine substitute for a short-lived unit of work or a bounded query.</p><h3>AsNoTracking does one job</h3><p>Moving the original query to no-tracking is a reasonable improvement when the application really needs entities:</p><pre>var orders = await db.Orders<br>    .AsNoTracking()<br>    .Include(o =&gt; o.Customer)<br>    .Where(o =&gt; o.Status == status)<br>    .ToListAsync(cancellationToken);</pre><p>EF Core no longer adds the results to the context tracker or creates the usual change-detection snapshots. But it still:</p><ul><li>fetches every matching row before the client-side Take;</li><li>selects the columns required to materialize Order and Customer entities;</li><li>constructs the entity graph;</li><li>buffers the complete result in the first list.</li></ul><p>Plain no-tracking also skips identity resolution. If joined rows repeat the same database identity, EF Core can create multiple CLR objects for it. Depending on the duplication ratio and graph shape, those duplicates can consume enough memory to reverse the simple assumption that no-tracking must always allocate less.</p><p>Tracking mode controls entity bookkeeping. Pagination controls cardinality. Projection controls the result shape. One switch cannot do all three jobs.</p><h3>Keep the query in SQL until it is small</h3><p>The revised version changes where the work happens:</p><pre>IQueryable&lt;Order&gt; query = db.Orders<br>    .Where(o =&gt; o.Status == status);<br><br>if (cursor is not null)<br>{<br>    query = query.Where(o =&gt;<br>        o.CreatedUtc &lt; cursor.CreatedUtc ||<br>        (o.CreatedUtc == cursor.CreatedUtc &amp;&amp; o.Id &lt; cursor.Id));<br>}<br><br>var page = await query<br>    .OrderByDescending(o =&gt; o.CreatedUtc)<br>    .ThenByDescending(o =&gt; o.Id)<br>    .Take(pageSize)<br>    .Select(o =&gt; new OrderListItem(<br>        o.Id,<br>        o.Number,<br>        o.CreatedUtc,<br>        o.Customer.Name,<br>        o.Total))<br>    .ToListAsync(cancellationToken);</pre><p>Filtering, deterministic ordering, the limit, and DTO construction now remain in the expression tree until the single terminal operation.</p><p>The fully unique order matters. Several orders can share CreatedUtc, so the cursor and ordering use both CreatedUtc and Id. Without a unique order, rows can be skipped or repeated between page requests. Microsoft recommends this keyset pattern for sequential navigation and notes that <a href="https://learn.microsoft.com/en-us/ef/core/querying/pagination">pagination ordering must be fully unique</a>.</p><p>Accessing o.Customer.Name inside the projection does not require Include. The provider generates the join needed for that scalar value. EF Core materializes OrderListItem objects, not Order and Customer entities, and only the selected DTO columns need to cross the database boundary.</p><p>On a fresh context, this should remain zero:</p><pre>db.ChangeTracker.Entries().Count()</pre><p>The result contains no entity instances, so there is nothing to track. Adding AsNoTracking may document intent, but it is normally redundant here. The important changes are the entity-free projection and the server-side limit.</p><p>The database still needs an index compatible with the filter and the descending keyset order. The exact index depends on the provider, data distribution, and workload; Take(50) doesn&#39;t rescue a query that must scan and sort a large table to find those 50 rows. This discussion targets relational providers. Azure Cosmos DB uses its own continuation-token mechanism.</p><h3>A projection can still track entities</h3><p>Select is not a magic no-tracking boundary. The shape of the projection decides whether entities are materialized. EF Core&#39;s <a href="https://learn.microsoft.com/en-us/ef/core/querying/tracking#tracking-and-custom-projections">tracking documentation</a> calls out both entity-containing projections and client projections explicitly.</p><p>This projection still exposes an entity:</p><pre>var rows = await db.Orders<br>    .Select(o =&gt; new<br>    {<br>        Order = o,<br>        CustomerName = o.Customer.Name<br>    })<br>    .ToListAsync(cancellationToken);</pre><p>Order is a keyed entity in the result, so EF Core tracks it under the default behavior.</p><p>A client method can produce the same surprise:</p><pre>var labels = await db.Orders<br>    .Select(o =&gt; FormatOrder(o))<br>    .ToListAsync(cancellationToken);</pre><p>EF Core supports client evaluation in the top-level projection. Passing the complete Order to client code requires materializing it; by default, that entity is tracked. Pass only the required scalar values instead:</p><pre>var labels = await db.Orders<br>    .Select(o =&gt; FormatOrder(o.Number, o.CreatedUtc, o.Total))<br>    .ToListAsync(cancellationToken);</pre><p>Since EF Core 3.0, an untranslatable expression outside the top-level projection generally throws rather than silently pulling data to the client. You can still cross the boundary explicitly with AsEnumerable, AsAsyncEnumerable, ToList, or ToListAsync. <a href="https://learn.microsoft.com/en-us/ef/core/querying/client-eval">AsEnumerable streams instead of creating a list</a>, but operators after it are still client-side. It doesn&#39;t turn an unbounded query back into a bounded SQL query.</p><h3>Four result shapes, four different costs</h3><p>When entities must be materialized, the right mode depends on what the caller will do with them:</p><pre>var tracked = await db.OrderLines<br>    .Include(line =&gt; line.Product)<br>    .Where(line =&gt; line.OrderId == orderId)<br>    .AsTracking()<br>    .ToListAsync(cancellationToken);<br><br>var detached = await db.OrderLines<br>    .Include(line =&gt; line.Product)<br>    .Where(line =&gt; line.OrderId == orderId)<br>    .AsNoTracking()<br>    .ToListAsync(cancellationToken);<br><br>var deduplicated = await db.OrderLines<br>    .Include(line =&gt; line.Product)<br>    .Where(line =&gt; line.OrderId == orderId)<br>    .AsNoTrackingWithIdentityResolution()<br>    .ToListAsync(cancellationToken);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0wqlGqwhmjnk5XTwucJQPA.png" /></figure><p><a href="https://learn.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.entityframeworkqueryableextensions.asnotrackingwithidentityresolution">AsNoTrackingWithIdentityResolution</a> has been available since EF Core 5. It uses a stand-alone tracker during enumeration, deduplicates instances without attaching them to the context, and lets that temporary tracker become collectible after enumeration. That bookkeeping isn&#39;t free. It can win when many rows repeat the same principal, and lose when duplication is low.</p><p>Use a fresh context for each variant if you test this. Pick two order lines that share a product key and compare their navigation properties with ReferenceEquals. Tracking and identity-resolution no-tracking should reuse the Product instance; plain no-tracking may not. Also record tracker entries, because object identity and context tracking are separate behaviors.</p><p>There is a version-specific edge case: starting with EF Core 9, <a href="https://learn.microsoft.com/en-us/ef/core/what-is-new/ef-core-9.0/breaking-changes#some-notrackingwithidentityresolution-queries-are-now-prohibited-for-json-collections">some queries that apply LINQ operators to JSON-mapped entity collections are prohibited with no-tracking identity resolution</a>. Use regular tracking when identity resolution is required for those shapes, or plain no-tracking when it isn’t.</p><p>If the response needs only product IDs and names, preserving entity identity is the wrong problem. Project the values.</p><h3>What Microsoft’s benchmark proves</h3><p>Microsoft’s <a href="https://learn.microsoft.com/en-us/ef/core/performance/efficient-querying">efficient-querying documentation</a> publishes this BenchmarkDotNet comparison for loading 10 blogs with 20 posts per blog:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*KJWHCumsv_-T_py9JJ5mqA.png" /></figure><p>That workload shows that tracking overhead is measurable. It doesn’t predict your endpoint.</p><p>The <a href="https://github.com/dotnet/EntityFramework.Docs/blob/main/samples/core/Benchmarks/QueryTrackingBehavior.cs">benchmark source</a> uses SQL Server LocalDB, MemoryDiagnoser, a new context for each operation, and an entity graph loaded with Include. It doesn&#39;t compare DTO projection, AsNoTrackingWithIdentityResolution, pagination, network cost, or production concurrency. The published page also doesn&#39;t provide enough current hardware, runtime, provider, and package metadata to turn those numbers into a general ratio.</p><p>Treat the figures as a reason to measure, not as a result to paste into a capacity plan.</p><h3>Measure the query you actually ship</h3><p>A useful benchmark compares four variants with identical predicates and a fresh context for every operation:</p><ol><li>Tracking entity graph.</li><li>AsNoTracking entity graph.</li><li>AsNoTrackingWithIdentityResolution entity graph.</li><li>Bounded, entity-free DTO projection.</li></ol><p>Parameterize result cardinality and the ratio of repeated principals. Cardinality exposes the cost of materializing too much. The duplication ratio shows when identity resolution saves enough objects to justify its lookup machinery.</p><p>Record allocated bytes per operation, elapsed time, GC collections, result count, and ChangeTracker.Entries().Count(). Keep query compilation out of steady-state measurements, or report cold and warm behavior separately. Document the exact EF Core version, provider and version, .NET runtime, database, page size, data distribution, and benchmark environment.</p><p>Then inspect behavior beyond the benchmark process:</p><ul><li>Use ToQueryString() or EF command logging to confirm that the limit is translated and only the required columns are selected.</li><li>Inspect the database execution plan and verify an index compatible with the filter, cursor predicate, and order.</li><li>Load-test the endpoint at representative concurrency while observing allocation rate, GC collections, managed heap size, and working set with <a href="https://learn.microsoft.com/en-us/dotnet/core/diagnostics/dotnet-counters">dotnet-counters</a>.</li><li>Measure peak live memory as well as total allocation. Short-lived tracking state can still overlap across requests.</li><li>Verify stable ordering and pagination under concurrent inserts and deletes, along with any object-identity assumptions in the consumer.</li></ul><p>Small queries can make every variant look harmless. Use cardinalities and duplication patterns that resemble the database the endpoint will face six months from now.</p><h3>The catch</h3><p>Tracking is the correct default when you read entities, change them, and call SaveChanges in one short unit of work. Querying without tracking and then attaching the graph back to the same context is usually more complicated and can be slower than letting EF Core track it from the start.</p><p>A small, already bounded entity query may not justify a refactor purely for memory. Projection can still reduce the SQL payload and make the API contract explicit, but complexity has a cost too.</p><p>Keyless entity types are never tracked, so the tracking part of this argument doesn’t apply to them. Pagination still does. Keyset pagination also isn’t suitable for arbitrary jumps to page 37; offset pagination may remain necessary when random access is a real requirement.</p><p>Streaming is useful for batch processing, but it isn’t a universal replacement for pagination in a user-facing API. It changes buffering behavior without placing a deterministic bound on the operation, and some execution strategies or query shapes can introduce internal buffering anyway.</p><h3>What should you use?</h3><ul><li>Read, modify, then call SaveChanges: use tracking.</li><li>Read entities without updating them, and duplicate object identity is irrelevant: use AsNoTracking.</li><li>Read a repeated entity graph without updates, but require one CLR instance per key: consider AsNoTrackingWithIdentityResolution and measure it.</li><li>Return an API or view model: project directly to an entity-free DTO.</li><li>Run any potentially large query: apply deterministic pagination or another hard limit before materialization, regardless of tracking mode.</li></ul><p>For a read-only endpoint, start with the shape you actually intend to return. Bound it in SQL, select only those values, and materialize once. AsNoTracking is useful when entities still need to exist. The cheapest tracked entity is the one you never create.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=236249ef9635" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LINQ Isn’t Slow]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@vikpoca/linq-isnt-slow-0248ae40b5c1?source=rss-043b7986232b------2"><img src="https://cdn-images-1.medium.com/max/1672/1*P-yLM3Rl1wk--0lTtJzZEA.png" width="1672"></a></p><p class="medium-feed-snippet">These LINQ Patterns Are</p><p class="medium-feed-link"><a href="https://medium.com/@vikpoca/linq-isnt-slow-0248ae40b5c1?source=rss-043b7986232b------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@vikpoca/linq-isnt-slow-0248ae40b5c1?source=rss-043b7986232b------2</link>
            <guid isPermaLink="false">https://medium.com/p/0248ae40b5c1</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[linq]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <dc:creator><![CDATA[Viktor Ponamarev]]></dc:creator>
            <pubDate>Sun, 09 Aug 2026 08:29:10 GMT</pubDate>
            <atom:updated>2026-08-09T08:29:10.946Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Stop Using Exceptions for Expected Failures]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@vikpoca/stop-using-exceptions-for-expected-failures-2b253b233673?source=rss-043b7986232b------2"><img src="https://cdn-images-1.medium.com/max/1536/1*jjPkaHuna83Uv8TzK-QvRA.png" width="1536"></a></p><p class="medium-feed-snippet">C# 15 Changes the Options</p><p class="medium-feed-link"><a href="https://medium.com/@vikpoca/stop-using-exceptions-for-expected-failures-2b253b233673?source=rss-043b7986232b------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@vikpoca/stop-using-exceptions-for-expected-failures-2b253b233673?source=rss-043b7986232b------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b253b233673</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[csharp]]></category>
            <dc:creator><![CDATA[Viktor Ponamarev]]></dc:creator>
            <pubDate>Thu, 06 Aug 2026 23:38:48 GMT</pubDate>
            <atom:updated>2026-08-07T06:19:51.594Z</atom:updated>
        </item>
    </channel>
</rss>