database-performance

Apply EF Core and Dapper data access patterns to optimize queries and prevent N+1 issues.

Updated Mar 14, 2026
One-click install
npx skills add https://github.com/akoken/one-piece --skill database-performance-akoken
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: database-performance
Source: https://github.com/akoken/one-piece/tree/main/skills/database-performance
Command: npx skills add https://github.com/akoken/one-piece --skill database-performance-akoken

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Database performance pain: inefficient data access patterns lead to slow queries, N+1 problems, and excessive change-tracking overhead. This Skill provides a structured set of patterns that apply across EF Core and Dapper to build fast, scalable data access layers.

Core Features & Use Cases

  • Read/Write model separation (CQRS) to avoid mixing concerns and optimize queries.
  • Always apply row limits to read queries to prevent unbounded result sets.
  • Use AsNoTracking for read-only operations to reduce tracking overhead.
  • Avoid N+1 queries by using Includes, batch queries, or explicit projections; perform joins in SQL rather than in application code.
  • Choose EF Core for simple CRUD and Dapper for complex reads; use them together in the same project.

Quick Start

Audit your data layer to separate read and write models, enable AsNoTracking on reads, and enforce per-query limits.

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

Fix N+1 query problems in EF Core by using Includes, batch queries, or explicit projections. Perform joins in SQL rather than application code to avoid fetching related data in separate loops.

Does AsNoTracking improve database read performance?

AsNoTracking improves database read performance by reducing change-tracking overhead. Apply it to read-only operations to prevent the context from storing entity state, yielding faster query execution.

When should I use Dapper instead of EF Core for data access?

Use Dapper for complex reads and EF Core for simple CRUD operations. You can use both together in the same project, applying Dapper where query optimization demands direct SQL control.

What is read and write model separation for database queries?

Read and write model separation is a CQRS pattern that optimizes database queries by splitting data access concerns. It ensures read operations are tailored for retrieval speed without affecting write logic.

How do I prevent unbounded result sets in database queries?

Prevent unbounded result sets in database queries by always applying row limits to read operations. Enforce server-side limits to restrict retrieval volume and protect application memory.

Why perform SQL joins over in-memory joins for data access?

Perform SQL joins over in-memory joins to optimize data access by leveraging database server processing. This approach prevents pulling large datasets into application memory and avoids N+1 queries.