Production engineering
using System;
using System.Linq;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
var rows=new[]{new Product(1,"books",30),new Product(2,"books",10),new Product(3,"books",20),new Product(4,"gear",20)};
Console.WriteLine(string.Join(",",rows.Where(x=>x.Category=="books").OrderBy(x=>x.Price).ThenBy(x=>x.Id).Select(x=>x.Id)));
record Product(int Id,string Category,int Price);
Reveal answer and reasoning
The companion contains four ordinary Product records. Filtering category books retains identifiers one, two and three with prices thirty, ten and twenty. Ordering by price and then identifier yields the single printed line 2,3,1. The additional gear record does not enter the result. LINQ establishes that logical ordering without a database, B-tree or optimizer. It does not count physical reads or establish that a server index is covering.
The explicit identifier tie-breaker also documents which ordering would apply if prices matched, rather than relying on an incidental original enumeration order.
The external endpoint runs the corresponding parameterized SQLite query and returns identifiers two, three and one. It separately exposes the actual plan for the literal fixture query with the same category value and ordering. The validation records that this pinned provider uses ix_products_category_price_id and checks the observation again on the same unchanged fixture. It does not compare milliseconds or hardcode the full prose of EXPLAIN into an application API.
Reading both result and plan prevents an attractive access-path description from concealing a wrong filter, wrong order or unexpectedly broad projection.
What a strong answer covers
- The logical companion and actual query return identifiers2,3,1.
- The fixture index begins with category and supports the stated price/id order.
- A provider-specific covering-plan observation is not a universal performance guarantee.
Common pitfall
Treating an index name or covering label as proof of correctness and universal speed.
Follow-up questions
- What happens to the required order when two prices tie?
- How does adding an unindexed projected column change the investigation?
Self-review
Choose what to revisit. These marks are your own assessment and are separate from lesson completion.