[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7D1PXHRTYBA3PY7B1SN686Z":3,"skill-same:01M7D1PXHRTYBA3PY7B1SN686Z":44},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":14,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":29,"install":30,"resources":43},"01M7D1PXHRTYBA3PY7B1SN686Z","optimizing-ef-core-queries",null,"Optimize and improve the performance of slow Entity Framework Core (EF Core) queries: make them generate less SQL, make fewer database round-trips, and return results faster. Use whenever an EF Core or DbContext query or data-access path is slow or should be made faster — whether or not EF Core owns the database schema. For EF Core, not Dapper or raw ADO.NET.","itsmejay18\u002FAI-Skills-for-My-Development-Stack","itsmejay18","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F167779943?v=4","01M7CZRFC6DDZA5V2CX8WDSZED","Jay Jemino Ababon ","01M7CZRFCVRNW1SFHSQXEJ3CQN",0,"MIT","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F07-Database-Development\u002Foptimizing-ef-core-queries\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: optimizing-ef-core-queries\ndescription: \"Optimize and improve the performance of slow Entity Framework Core (EF Core) queries: make them generate less SQL, make fewer database round-trips, and return results faster. Use whenever an EF Core or DbContext query or data-access path is slow or should be made faster — whether or not EF Core owns the database schema. For EF Core, not Dapper or raw ADO.NET.\"\nlicense: MIT\n---\n\n# Optimizing EF Core Queries\n\nDiagnose and fix slow Entity Framework Core (EF Core) queries. Start from the generated SQL\u002Flogs, apply the smallest change that removes the bottleneck, and confirm the fix by re-reading the SQL and the query count. Prefer changes that reduce round-trips, duplicated rows, scans, or per-call translation cost over micro-optimizations. Apply one change at a time and re-measure.\n\n## When to Use\n\n- EF Core queries are slow or emit far more SQL statements than expected\n- The same query repeats once per row (N+1 \u002F lazy loading)\n- Multiple collection `Include`s blow up or duplicate rows\n- Deep pages slow down as `Skip` grows, or bulk updates load rows just to modify them\n- A filtered\u002Fsorted query scans **even though the column is indexed**, or a filtered\u002Fsorted column has no supporting index\n- A hot, frequently-executed query pays EF Core's LINQ-translation cost on every call\n\n## When Not to Use\n\n- **The code uses Dapper or raw ADO.NET, not EF Core.** Answer the SQL\u002Findexing\u002Fquery-plan question directly; do not introduce a `DbContext` or recommend `AsNoTracking`, `Include`, `AsSplitQuery`, or other EF Core APIs.\n\n## First: capture the generated SQL\n\nYou cannot optimize what you cannot see. Turn on command logging and read the SQL and query count before changing anything:\n\n```csharp\noptionsBuilder.LogTo(Console.WriteLine, LogLevel.Information);\n\u002F\u002F or set \"Microsoft.EntityFrameworkCore.Database.Command\": \"Information\" in appsettings.json\n```\n\nTag a query with `.TagWith(\"...\")` to find it in the log. Count how many statements a slow operation runs, and how many rows each returns, before and after each change.\n\n## Fixes\n\n### Keep predicates sargable — never wrap an indexed column in a function\n\nAn index can only be used when the indexed column appears **bare** on one side of the comparison. Wrapping it in a function or arithmetic — `CreatedAt.Year == y`, `CreatedAt.Date == d`, `ToLower(Name) == n`, `Price * 1.1 > x`, or a leading-wildcard `LIKE '%foo'` — forces a per-row computation the index cannot satisfy, so the query **scans the whole table even though the index exists**. Adding another index changes nothing. Rewrite the predicate so the column stays bare, usually as a half-open range:\n\n```csharp\n\u002F\u002F Non-sargable: a function is computed for every row → full scan\ndb.Logs.Where(l => l.CreatedAt.Year == year);\n\n\u002F\u002F Sargable: bare column compared to constants → index seek\nvar start = new DateTime(year, 1, 1);\ndb.Logs.Where(l => l.CreatedAt >= start && l.CreatedAt \u003C start.AddYears(1));\n```\n\nThe same rule covers several common shapes:\n\n- **Case-insensitive text** — compare a stored normalized column instead of `ToLower(...)`\u002F`ToUpper(...)`.\n- **Computed expressions** — compare against the precomputed constant, not `column * k > x`.\n- **Converting the column to another type** — a predicate over `column.ToString()` (for example matching the *text form* of a number or date, `total.ToString().StartsWith(p)`) applies a function to every row and often can't be translated to SQL at all, forcing a client-side evaluation that pulls the whole table into memory. Filter on the typed column with a real comparison or range instead.\n- **Substring search** — `name.Contains(term)` becomes an unanchored `LIKE '%term%'` that can't seek an index and scans the table; a trailing-wildcard prefix (`name.StartsWith(term)` → `'term%'`) can seek. Anchor the search when a prefix match is acceptable — this changes which rows match, so confirm the behavior first — and put real substring or fuzzy search behind a full-text index on large tables.\n\n**Verify:** the plan shows a seek\u002Findex instead of a scan and duration drops. If the column genuinely has no index, add one (see below) — but only after the predicate is sargable.\n\n### Compile hot, frequently-executed queries\n\nOn a very hot path that runs the *same* query shape thousands of times over a reused context, EF Core re-parses the LINQ expression tree and probes its query cache on every call. When the query is already minimal (an indexed lookup or a small projection) and read-only tweaks such as `AsNoTracking` buy nothing, that per-call translation is the remaining cost. Compile the query once with `EF.CompileQuery` \u002F `EF.CompileAsyncQuery` and reuse the delegate:\n\n```csharp\nprivate static readonly Func\u003CAppDbContext, int, ProductListItem> GetProduct =\n    EF.CompileQuery((AppDbContext db, int id) =>\n        db.Products.Where(p => p.Id == id)\n                   .Select(p => new ProductListItem(p.Id, p.Name, p.Price))\n                   .First());\n\npublic ProductListItem Lookup(AppDbContext db, int id) => GetProduct(db, id);\n```\n\nThe delegate is `static` (compiled once) and takes the `DbContext` plus each parameter as arguments. Use it for endpoints or loops that execute one query shape at very high frequency; it does nothing for one-off queries.\n\n**Verify:** the hot loop's mean time drops with identical results.\n\n### Remove N+1 and avoid lazy loading\n\nThe same `SELECT` repeated once per row (a navigation accessed inside a loop) is an N+1. Load the related data in one round-trip — project the aggregates with `Select`, or eager-load with `Include`:\n\n```csharp\nvar summaries = await db.Orders\n    .Select(o => new OrderSummary(o.Id, o.Items.Count, o.Items.Sum(i => i.Price)))\n    .ToListAsync();\n```\n\nPrefer projection or `Include` over lazy loading: lazy loading is a leading cause of N+1 and forces synchronous I\u002FO. In server apps, don't enable `Microsoft.EntityFrameworkCore.Proxies` or mark navigations `virtual` for lazy loading.\n\n**Verify:** a fixed, small query count regardless of row count.\n\n### Split multiple collection Includes\n\n`Include`ing two or more collection navigations in one query multiplies rows (a Cartesian explosion) and duplicates parent data. Use `AsSplitQuery()` so each collection loads in its own statement; add `OrderBy` on a unique key so rows stitch together:\n\n```csharp\ndb.Blogs.Include(b => b.Posts).Include(b => b.Contributors).AsSplitQuery();\n```\n\n**Verify:** rows per statement drop sharply and total duration improves.\n\n### Filter and paginate; prefer keyset over offset\n\nConstrain large result sets with `Where`, and page with **keyset (seek)** pagination rather than `Skip`\u002F`Take`, which still scans and discards the skipped rows on deep pages:\n\n```csharp\ndb.Orders.Where(o => o.Id > lastSeenId).OrderBy(o => o.Id).Take(pageSize);\n```\n\nOrder by a unique, stable, indexed key (add tie-breakers if the sort column isn't unique). Keyset pages by the *last key seen* rather than a page number, so it changes the method's inputs; when a fixed signature rules out an in-place switch, still flag the deep-offset scan and recommend keyset.\n\n**Verify:** page latency stays roughly constant from early to deep pages.\n\n### Add missing indexes\n\nMoving a filter into SQL or making a predicate sargable stops the *client-side* waste, but a `WHERE` or `ORDER BY` on a column with no index still scans the whole table inside the database — and a frequently-run query then re-scans it on every call. So audit index coverage separately from the query rewrite: for each query, check whether its filter and sort columns are backed by an index. Entity keys and foreign keys are indexed by convention, but other columns — status flags, state\u002Fenum fields, timestamps, names — usually are **not** unless the model configures it. When a hot query filters or sorts on such an unindexed column, recommend adding an index and say so explicitly, even when the rewritten query already returns the right rows: the index is a separate fix the code change alone doesn't deliver. (If the predicate isn't sargable, fix that first — a new index can't help a scan caused by a function on the column.)\n\nIf EF Core owns the schema, add the index in the model and migrate:\n\n```csharp\nmodelBuilder.Entity\u003COrder>()\n    .HasIndex(o => new { o.CustomerId, o.CreatedAt }); \u002F\u002F equality column first, then range\u002Fsort\n```\n\nThen create the migration with `dotnet ef migrations add ...`. **Do not apply it** with `dotnet ef database update` (or any equivalent that writes to the database) without explicit user approval — applying a migration mutates the database, so add the migration, show it to the user, and let them run the update once they've reviewed it. If EF Core does not own the schema, recommend the same index to whoever manages the database. Don't over-index — every index slows writes.\n\n**Verify:** the plan uses a seek\u002Findex instead of a scan.\n\n### Set-based bulk updates and deletes\n\nReplace a load-mutate-`SaveChanges` loop with `ExecuteUpdateAsync`\u002F`ExecuteDeleteAsync` (EF Core 7+) — one statement, no entities materialized:\n\n```csharp\nawait db.Products.Where(p => p.LastSoldDate \u003C cutoff)\n    .ExecuteUpdateAsync(s => s.SetProperty(p => p.IsActive, false));\n```\n\nThese bypass the change tracker and EF-side cascade behavior — apply related changes explicitly.\n\n**Verify:** a single `UPDATE`\u002F`DELETE` with a `WHERE` and no preceding `SELECT`.\n\n## Common Pitfalls\n\n| Pitfall | Fix |\n|---------|-----|\n| Wrapping an indexed column in `.Year`\u002F`.Date`\u002F`ToLower`\u002Farithmetic | Rewrite to a sargable range\u002Fcomparison on the bare column |\n| Adding an index to fix a scan on a non-sargable predicate | Fix the predicate first; the index can't help until the column is bare |\n| Rewriting a filter into SQL but leaving a hot query on an unindexed column | The server-side scan is still a scan — recommend an index on the filter\u002Fsort column too |\n| Compiling a query that runs only occasionally | Compile only genuinely hot, high-frequency query shapes |\n| Lazy loading (proxies \u002F `virtual` navigations) causing N+1 and forced sync I\u002FO | Eager-load (`Include`) or project; keep queries async |\n| `ToList()`\u002F`AsEnumerable()` before `Where`\u002F`Select` | Keep the query `IQueryable` so filtering\u002Fprojection run in SQL |\n\n## References\n\n- [Efficient querying — EF Core](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fef\u002Fcore\u002Fperformance\u002Fefficient-querying)\n- [Compiled queries — EF Core](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fef\u002Fcore\u002Fperformance\u002Fadvanced-performance-topics#compiled-queries)\n- [Efficient updating (ExecuteUpdate\u002FExecuteDelete) — EF Core](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fef\u002Fcore\u002Fperformance\u002Fefficient-updating)\n- [Single vs. split queries](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fef\u002Fcore\u002Fquerying\u002Fsingle-split-queries)\n- [Pagination](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fef\u002Fcore\u002Fquerying\u002Fpagination)\n- [Indexes](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fef\u002Fcore\u002Fmodeling\u002Findexes)\n","# Optimizing EF Core Queries\n\nDiagnose and fix slow Entity Framework Core (EF Core) queries. Start from the generated SQL\u002Flogs, apply the smallest change that removes the bottleneck, and confirm the fix by re-reading the SQL and the query count. Prefer changes that reduce round-trips, duplicated rows, scans, or per-call translation cost over micro-optimizations. Apply one change at a time and re-measure.\n\n## When to Use\n\n- EF Core queries are slow or emit far more SQL statements than expected\n- The same query repeats once per row (N+1 \u002F lazy loading)\n- Multiple collection `Include`s blow up or duplicate rows\n- Deep pages slow down as `Skip` grows, or bulk updates load rows just to modify them\n- A filtered\u002Fsorted query scans **even though the column is indexed**, or a filtered\u002Fsorted column has no supporting index\n- A hot, frequently-executed query pays EF Core's LINQ-translation cost on every call\n\n## When Not to Use\n\n- **The code uses Dapper or raw ADO.NET, not EF Core.** Answer the SQL\u002Findexing\u002Fquery-plan question directly; do not introduce a `DbContext` or recommend `AsNoTracking`, `Include`, `AsSplitQuery`, or other EF Core APIs.\n\n## First: capture the generated SQL\n\nYou cannot optimize what you cannot see. Turn on command logging and read the SQL and query count before changing anything:\n\n```csharp\noptionsBuilder.LogTo(Console.WriteLine, LogLevel.Information);\n\u002F\u002F or set \"Microsoft.EntityFrameworkCore.Database.Command\": \"Information\" in appsettings.json\n```\n\nTag a query with `.TagWith(\"...\")` to find it in the log. Count how many statements a slow operation runs, and how many rows each returns, before and after each change.\n\n## Fixes\n\n### Keep predicates sargable — never wrap an indexed column in a function\n\nAn index can only be used when the indexed column appears **bare** on one side of the comparison. Wrapping it in a function or arithmetic — `CreatedAt.Year == y`, `CreatedAt.Date == d`, `ToLower(Name) == n`, `Price * 1.1 > x`, or a leading-wildcard `LIKE '%foo'` — forces a per-row computation the index cannot satisfy, so the query **scans the whole table even though the index exists**. Adding another index changes nothing. Rewrite the predicate so the column stays bare, usually as a half-open range:\n\n```csharp\n\u002F\u002F Non-sargable: a function is computed for every row → full scan\ndb.Logs.Where(l => l.CreatedAt.Year == year);\n\n\u002F\u002F Sargable: bare column compared to constants → index seek\nvar start = new DateTime(year, 1, 1);\ndb.Logs.Where(l => l.CreatedAt >= start && l.CreatedAt \u003C start.AddYears(1));\n```\n\nThe same rule covers several common shapes:\n\n- **Case-insensitive text** — compare a stored normalized column instead of `ToLower(...)`\u002F`ToUpper(...)`.\n- **Computed expressions** — compare against the precomputed constant, not `column * k > x`.\n- **Converting the column to another type** — a predicate over `column.ToString()` (for example matching the *text form* of a number or date, `total.ToString().StartsWith(p)`) applies a function to every row and often can't be translated to SQL at all, forcing a client-side evaluation that pulls the whole table into memory. Filter on the typed column with a real comparison or range instead.\n- **Substring search** — `name.Contains(term)` becomes an unanchored `LIKE '%term%'` that can't seek an index and scans the table; a trailing-wildcard prefix (`name.StartsWith(term)` → `'term%'`) can seek. Anchor the search when a prefix match is acceptable — this changes which rows match, so confirm the behavior first — and put real substring or fuzzy search behind a full-text index on large tables.\n\n**Verify:** the plan shows a seek\u002Findex instead of a scan and duration drops. If the column genuinely has no index, add one (see below) — but only after the predicate is sargable.\n\n### Compile hot, frequently-executed queries\n\nOn a very hot path that runs the *same* query shape thousands of times over a reused context, EF Core re-parses the LINQ expression tree and probes its query cache on every call. When the query is already minimal (an indexed lookup or a small projection) and read-only tweaks such as `AsNoTracking` buy nothing, that per-call translation is the remaining cost. Compile the query once with `EF.CompileQuery` \u002F `EF.CompileAsyncQuery` and reuse the delegate:\n\n```csharp\nprivate static readonly Func\u003CAppDbContext, int, ProductListItem> GetProduct =\n    EF.CompileQuery((AppDbContext db, int id) =>\n        db.Products.Where(p => p.Id == id)\n                   .Select(p => new ProductListItem(p.Id, p.Name, p.Price))\n                   .First());\n\npublic ProductListItem Lookup(AppDbContext db, int id) => GetProduct(db, id);\n```\n\nThe delegate is `static` (compiled once) and takes the `DbContext` plus each parameter as arguments. Use it for endpoints or loops that execute one query shape at very high frequency; it does nothing for one-off queries.\n\n**Verify:** the hot loop's mean time drops with identical results.\n\n### Remove N+1 and avoid lazy loading\n\nThe same `SELECT` repeated once per row (a navigation accessed inside a loop) is an N+1. Load the related data in one round-trip — project the aggregates with `Select`, or eager-load with `Include`:\n\n```csharp\nvar summaries = await db.Orders\n    .Select(o => new OrderSummary(o.Id, o.Items.Count, o.Items.Sum(i => i.Price)))\n    .ToListAsync();\n```\n\nPrefer projection or `Include` over lazy loading: lazy loading is a leading cause of N+1 and forces synchronous I\u002FO. In server apps, don't enable `Microsoft.EntityFrameworkCore.Proxies` or mark navigations `virtual` for lazy loading.\n\n**Verify:** a fixed, small query count regardless of row count.\n\n### Split multiple collection Includes\n\n`Include`ing two or more collection navigations in one query multiplies rows (a Cartesian explosion) and duplicates parent data. Use `AsSplitQuery()` so each collection loads in its own statement; add `OrderBy` on a unique key so rows stitch together:\n\n```csharp\ndb.Blogs.Include(b => b.Posts).Include(b => b.Contributors).AsSplitQuery();\n```\n\n**Verify:** rows per statement drop sharply and total duration improves.\n\n### Filter and paginate; prefer keyset over offset\n\nConstrain large result sets with `Where`, and page with **keyset (seek)** pagination rather than `Skip`\u002F`Take`, which still scans and discards the skipped rows on deep pages:\n\n```csharp\ndb.Orders.Where(o => o.Id > lastSeenId).OrderBy(o => o.Id).Take(pageSize);\n```\n\nOrder by a unique, stable, indexed key (add tie-breakers if the sort column isn't unique). Keyset pages by the *last key seen* rather than a page number, so it changes the method's inputs; when a fixed signature rules out an in-place switch, still flag the deep-offset scan and recommend keyset.\n\n**Verify:** page latency stays roughly constant from early to deep pages.\n\n### Add missing indexes\n\nMoving a filter into SQL or making a predicate sargable stops the *client-side* waste, but a `WHERE` or `ORDER BY` on a column with no index still scans the whole table inside the database — and a frequently-run query then re-scans it on every call. So audit index coverage separately from the query rewrite: for each query, check whether its filter and sort columns are backed by an index. Entity keys and foreign keys are indexed by convention, but other columns — status flags, state\u002Fenum fields, timestamps, names — usually are **not** unless the model configures it. When a hot query filters or sorts on such an unindexed column, recommend adding an index and say so explicitly, even when the rewritten query already returns the right rows: the index is a separate fix the code change alone doesn't deliver. (If the predicate isn't sargable, fix that first — a new index can't help a scan caused by a function on the column.)\n\nIf EF Core owns the schema, add the index in the model and migrate:\n\n```csharp\nmodelBuilder.Entity\u003COrder>()\n    .HasIndex(o => new { o.CustomerId, o.CreatedAt }); \u002F\u002F equality column first, then range\u002Fsort\n```\n\nThen create the migration with `dotnet ef migrations add ...`. **Do not apply it** with `dotnet ef database update` (or any equivalent that writes to the database) without explicit user approval — applying a migration mutates the database, so add the migration, show it to the user, and let them run the update once they've reviewed it. If EF Core does not own the schema, recommend the same index to whoever manages the database. Don't over-index — every index slows writes.\n\n**Verify:** the plan uses a seek\u002Findex instead of a scan.\n\n### Set-based bulk updates and deletes\n\nReplace a load-mutate-`SaveChanges` loop with `ExecuteUpdateAsync`\u002F`ExecuteDeleteAsync` (EF Core 7+) — one statement, no entities materialized:\n\n```csharp\nawait db.Products.Where(p => p.LastSoldDate \u003C cutoff)\n    .ExecuteUpdateAsync(s => s.SetProperty(p => p.IsActive, false));\n```\n\nThese bypass the change tracker and EF-side cascade behavior — apply related changes explicitly.\n\n**Verify:** a single `UPDATE`\u002F`DELETE` with a `WHERE` and no preceding `SELECT`.\n\n## Common Pitfalls\n\n| Pitfall | Fix |\n|---------|-----|\n| Wrapping an indexed column in `.Year`\u002F`.Date`\u002F`ToLower`\u002Farithmetic | Rewrite to a sargable range\u002Fcomparison on the bare column |\n| Adding an index to fix a scan on a non-sargable predicate | Fix the predicate first; the index can't help until the column is bare |\n| Rewriting a filter into SQL but leaving a hot query on an unindexed column | The server-side scan is still a scan — recommend an index on the filter\u002Fsort column too |\n| Compiling a query that runs only occasionally | Compile only genuinely hot, high-frequency query shapes |\n| Lazy loading (proxies \u002F `virtual` navigations) causing N+1 and forced sync I\u002FO | Eager-load (`Include`) or project; keep queries async |\n| `ToList()`\u002F`AsEnumerable()` before `Where`\u002F`Select` | Keep the query `IQueryable` so filtering\u002Fprojection run in SQL |\n\n## References\n\n- [Efficient querying — EF Core](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fef\u002Fcore\u002Fperformance\u002Fefficient-querying)\n- [Compiled queries — EF Core](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fef\u002Fcore\u002Fperformance\u002Fadvanced-performance-topics#compiled-queries)\n- [Efficient updating (ExecuteUpdate\u002FExecuteDelete) — EF Core](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fef\u002Fcore\u002Fperformance\u002Fefficient-updating)\n- [Single vs. split queries](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fef\u002Fcore\u002Fquerying\u002Fsingle-split-queries)\n- [Pagination](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fef\u002Fcore\u002Fquerying\u002Fpagination)\n- [Indexes](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fef\u002Fcore\u002Fmodeling\u002Findexes)\n",{"name":5,"license":15,"description":7},"main","30954af1dcd1a74b63f05deb2e2c41e5ecae4a82","07-Database-Development\u002Foptimizing-ef-core-queries","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack","https:\u002F\u002Fgithub.com\u002Fitsmejay18","2026-09-18 16:06:36",{"source":8,"skillName":5,"commands":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add itsmejay18\u002FAI-Skills-for-My-Development-Stack --skill optimizing-ef-core-queries",{"tool":36,"command":37},"bunx","bunx skills add itsmejay18\u002FAI-Skills-for-My-Development-Stack --skill optimizing-ef-core-queries",{"tool":39,"command":40},"pnpm","pnpm dlx skills add itsmejay18\u002FAI-Skills-for-My-Development-Stack --skill optimizing-ef-core-queries","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F07-Database-Development\u002Foptimizing-ef-core-queries\u002FSKILL.md",true,[],[45,52,59,64,71,78],{"skillNo":46,"name":47,"nameZh":6,"description":48,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":49,"categories":50,"keywords":51,"publishedAt":19},"01M7D2RKBHPZ3E1RNN5DWHT550","vectorization","Design, implement, optimize, and review SIMD code in .NET. USE FOR: vectorizing scalar loops with TensorPrimitives, Vector64\u002F128\u002F256\u002F512, or platform hardware intrinsics; reviewing existing SIMD code, including Vector\u003CT>, for contract equivalence, tail handling, memory safety, portability, fallbacks, and measured performance. DO NOT USE FOR: performance work unrelated to SIMD or vectorization.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Fvectorization\u002FSKILL.md",[],[],{"skillNo":53,"name":54,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":56,"categories":57,"keywords":58,"publishedAt":19},"01M7D2RDJ7RN3QK8GJR0QTER1D","resolve-project-references","Guide for interpreting ResolveProjectReferences time in MSBuild performance summaries. Activate when ResolveProjectReferences appears as the most expensive target and developers are trying to optimize it directly. Explains that the reported time includes wait time for dependent project builds and is misleading. Guides users to focus on task self-time instead. Do not activate for general build performance -- use build-perf-diagnostics instead.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Fresolve-project-references\u002FSKILL.md",[],[],{"skillNo":60,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":61,"categories":62,"keywords":63,"publishedAt":19},"01M7D2R1H2GTNZYHG9YRX3JDQW","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Foptimizing-ef-core-queries\u002FSKILL.md",[],[],{"skillNo":65,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":19},"01M7D2QREG04W1YT0NEBHEW5C9","microbenchmarking","Activate this skill when BenchmarkDotNet (BDN) is involved in the task — creating, running, configuring, or reviewing BDN benchmarks. Also activate when microbenchmarking .NET code would be useful and BenchmarkDotNet is the likely tool. Consider activating when answering a .NET performance question requires measurement and BenchmarkDotNet may be needed. Covers microbenchmark design, BDN configuration and project setup, how to run BDN microbenchmarks efficiently and effectively, and using BDN for side-by-side performance comparisons. Do NOT use for profiling\u002Ftracing .NET code (dotnet-trace, PerfView), production telemetry, or load\u002Fstress testing (Crank, k6).","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Fmicrobenchmarking\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":19},"01M7D2QGE175XWPZVACVH2868Z","incremental-build","Guide for optimizing MSBuild incremental builds. USE FOR: builds slower than expected on subsequent runs, 'nothing changed but it rebuilds anyway', diagnosing why targets re-execute unnecessarily, fixing broken no-op builds. Covers 8 common causes: missing Inputs\u002FOutputs on custom targets, volatile properties in output paths (timestamps\u002FGUIDs), file writes outside tracked Outputs, missing FileWrites registration, glob changes, Visual Studio Fast Up-to-Date Check (FUTDC) issues. Key diagnostic: look for 'Building target completely' vs 'Skipping target' in binlog. DO NOT USE FOR: first-time build slowness (use build-perf-baseline), parallelism issues (use build-parallelism), evaluation-phase slowness (use eval-performance), non-MSBuild build systems.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Fincremental-build\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":19},"01M7D2Q1DQTC6K49R73WQTTPSB","eval-performance","Guide for diagnosing and improving MSBuild project evaluation performance. USE FOR: builds slow before any compilation starts, high evaluation time in binlog analysis, expensive glob patterns walking large directories (node_modules, .git, bin\u002Fobj), deep import chains (>20 levels), preprocessed output >10K lines indicating heavy evaluation, property functions with file I\u002FO ($([System.IO.File]::ReadAllText(...))), multiple evaluations per project. Covers the 5 MSBuild evaluation phases, glob optimization via DefaultItemExcludes, import chain analysis with \u002Fpp preprocessing. DO NOT USE FOR: compilation-time slowness (use build-perf-diagnostics), incremental build issues (use incremental-build), non-MSBuild build systems.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Feval-performance\u002FSKILL.md",[],[]]