database-performance

Optimize EF Core and Dapper data access with read/write model separation and per-query limits.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/tvcosta/ai-customer-service --skill database-performance-tvcosta
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: database-performance
Source: https://github.com/tvcosta/ai-customer-service/tree/main/.claude/skills/database-performance
Command: npx skills add https://github.com/tvcosta/ai-customer-service --skill database-performance-tvcosta

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides guidelines to optimize database access by separating read and write models, avoiding N+1 queries, and applying safe querying practices when using EF Core and Dapper.

Core Features & Use Cases

  • Separate read and write models to optimize query performance and maintain clear boundaries between reads and writes.
  • Avoid N+1 queries by using eager loading, batch queries, and proper projections.
  • Enforce per-query row limits and encourage SQL-side joins over application-side joins.

Quick Start

Configure a read/write data access layer that enforces per-query limits and avoids in-memory joins.

Frequently Asked Questions about database-performance

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

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

To avoid N+1 queries in EF Core, apply eager loading, batch queries, and proper projections. This ensures related data is fetched efficiently in a single database round trip rather than executing separate queries for each entity.

What is the best way to separate read and write models for database performance?

Separating read and write models optimizes query performance by establishing clear boundaries. Use AsNoTracking for reads to skip change tracking overhead, and direct write operations through dedicated modification paths to enforce per-query row limits.

Does using Dapper with EF Core improve query optimization?

Using Dapper alongside EF Core improves query optimization by allowing precise SQL-side joins and specialized read operations. This combination enforces safe querying practices across data access layers while maintaining strict per-query row limits.

Why should I enforce per-query row limits instead of application-side joins?

Enforcing per-query row limits prevents unbounded result sets, while SQL-side joins outperform application-side joins by leveraging database engine optimizations. This approach avoids loading excessive data into memory and reduces network latency.

How do I configure a read/write data access layer that prevents in-memory joins?

Configure a data access layer using frontmatter-driven entries with required names and descriptions. This setup enforces per-query limits, applies AsNoTracking for reads, and processes joins directly on the SQL server side.