database-performance

Optimize .NET database access with CQRS, AsNoTracking, and SQL joins.

71|10|Updated Feb 11, 2026
One-click install
npx skills add https://github.com/wshaddix/dotnet-skills --skill database-performance-wshaddix
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: database-performance
Source: https://github.com/wshaddix/dotnet-skills/tree/main/skills/database-performance
Command: npx skills add https://github.com/wshaddix/dotnet-skills --skill database-performance-wshaddix

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses common performance bottlenecks in database interactions, ensuring applications are fast, efficient, and scalable by preventing slow queries and excessive data retrieval.

Core Features & Use Cases

  • Read/Write Separation: Implement CQRS patterns for optimized data access.
  • Query Optimization: Avoid N+1 queries, use AsNoTracking, and apply row limits.
  • Efficient Joins: Ensure joins are performed in SQL, not in application code.
  • Use Case: When experiencing slow load times on a dashboard that displays many related records, use this skill to refactor the data access layer to use batched queries and projections.

Quick Start

Use the database-performance skill to refactor the data access layer to use batched queries and projections.

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 query issues in EF Core?

To fix N+1 query issues in EF Core, you should refactor your data access layer to use batched queries and SQL-based joins instead of retrieving related records in application code. This prevents excessive database round trips and improves load times.

What is the best way to optimize read queries for speed in .NET?

The best way to optimize read queries for speed in .NET is to apply the AsNoTracking method to your EF Core queries. This prevents the change tracker from storing entity state, reducing memory overhead and improving query execution speed for read-only data.

How does read/write model separation improve database performance?

Read/write model separation improves database performance by implementing CQRS patterns to optimize data access. This approach splits read and write operations into distinct models, allowing read queries to use projections and AsNoTracking while write operations handle state mutations.

When should I choose Dapper over EF Core for database optimization?

You should choose Dapper over EF Core for database optimization when you need to execute raw SQL-based joins and require fine-grained control over query execution. Dapper is often preferred for read-heavy scenarios where EF Core's change tracking adds unnecessary overhead.

Why are my dashboard load times slow when displaying many related records?

Dashboard load times are slow when displaying many related records due to retrieving excessive data and performing joins in application code. You can resolve this by using batched queries, applying row limits, and utilizing projections to fetch only the required fields.

Are there limitations to using SQL-based joins for data access optimization?

A limitation of relying strictly on SQL-based joins for data access optimization is the increased complexity of mapping flat result sets to complex object graphs. While it prevents N+1 queries, you must manually handle projections and ensure row limits are applied to avoid retrieving excessive data.