database-performance

Optimize .NET data access with EF Core and Dapper patterns.

1.1k|101|Updated Nov 12, 2025
One-click install
npx skills add https://github.com/Aaronontheweb/dotnet-skills --skill database-performance-aaronontheweb
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: database-performance
Source: https://github.com/Aaronontheweb/dotnet-skills/tree/main/skills/database-performance
Command: npx skills add https://github.com/Aaronontheweb/dotnet-skills --skill database-performance-aaronontheweb

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps teams design data access layers that are fast and scalable by avoiding N+1 queries, minimizing data transfer, and preventing application-side joins. It promotes clear separation of read and write models, and emphasizes batching and paging to tame query costs.

Core Features & Use Cases

  • Read/Write separation (CQRS) to optimize queries and maintain consistency between reads and writes
  • Enforced row limits and paging to prevent unbounded result sets
  • Prefer SQL-based joins over in-memory joins to minimize data transfer
  • AsNoTracking for read queries to reduce change-tracking overhead
  • Techniques to avoid N+1 queries, including Include/batch queries and projection-based reads

Quick Start

  • Configure read queries to use AsNoTracking and apply a limit to all read operations
  • Architect a simple ReadStore for denormalized read models and a separate WriteStore for commands
  • Example: implement a paged read path (GetAllAsync with limit) for a common admin or reporting view

Frequently Asked Questions about database-performance

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix N+1 queries in EF Core?▼

Avoid N+1 queries in EF Core by using Include, batch queries, and projection-based reads to enforce SQL joins over in-memory joins, minimizing data transfer and preventing Cartesian explosions.

What's the best way to optimize EF Core read performance for large datasets?▼

Optimize EF Core read performance by enforcing AsNoTracking to reduce change-tracking overhead, applying explicit pagination, and implementing row limits to prevent unbounded result sets in read queries.

Should I use read/write separation with Dapper and EF Core?▼

Implement read/write separation by architecting a denormalized ReadStore for queries and a separate WriteStore for commands, optimizing fast reads while maintaining write consistency.

How do I prevent Cartesian explosions in .NET data access?▼

Prevent Cartesian explosions in .NET data access by preferring SQL-based joins over in-memory joins, applying explicit pagination, and enforcing row limits on all read operations.

Does AsNoTracking improve query speed in EF Core?▼

Yes, AsNoTracking improves query speed in EF Core by reducing change-tracking overhead. Enforce it specifically for read queries to optimize data access performance.

Why are my EF Core in-memory joins causing high data transfer?▼

EF Core in-memory joins cause high data transfer by loading unnecessary entities. Prefer SQL-based joins and projection-based reads to fetch only required data at the database level.