koan-performance

Stream large datasets in batches with bulk operations and fast counts in Koan Framework.

4|3|Updated Aug 18, 2025
One-click install
npx skills add https://github.com/sylin-org/koan-framework --skill koan-performance
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: koan-performance
Source: https://github.com/sylin-org/koan-framework/tree/main/.claude/skills/performance
Command: npx skills add https://github.com/sylin-org/koan-framework --skill koan-performance

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Handling large datasets and high-traffic scenarios often leads to performance bottlenecks, N+1 queries, and out-of-memory errors. This Skill provides proven patterns and tools within Koan Framework to build highly performant and scalable applications from the ground up.

Core Features & Use Cases

  • Memory-Efficient Streaming: Process millions of records without exhausting memory by streaming data in batches instead of loading everything at once.
  • Optimized Count Strategies: Get accurate or estimated record counts thousands of times faster using metadata-based "Fast" counts for UI, and "Exact" counts for critical logic.
  • Bulk Operations: Perform mass create, update, or delete operations with a single, highly optimized database call, dramatically reducing execution time.
  • Batch Retrieval: Eliminate N+1 query problems by fetching multiple entities by ID in a single, efficient database query.
  • Pagination for APIs: Implement robust pagination for web APIs, providing total counts for rich user interfaces.
  • Use Case: Process a daily batch of 100,000 sensor readings without memory issues using streaming, update thousands of product prices in a single transaction, or display a dashboard with real-time (estimated) counts of active users.

Quick Start

To stream all 'Todo' entities in batches of 1000 to avoid memory issues: await foreach (var todo in Todo.AllStream(batchSize: 1000)) { // Process todo } To get a fast, estimated count of all 'Todo' entities for a dashboard: var fastCount = await Todo.Count.Fast();

Frequently Asked Questions about koan-performance

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

FAQPage Schema
How do I process millions of records without running out of memory?

Stream large datasets in batches instead of loading everything at once. Koan Framework's streaming patterns process records incrementally, eliminating out-of-memory errors when handling millions of entities in data pipelines and batch jobs.

How can I eliminate N+1 query problems in my API?

Batch retrieval fetches multiple entities by ID in a single optimized database query, eliminating N+1 problems common in API layers. Pagination support provides total counts for rich interfaces without repeated queries.

What's the fastest way to get record counts for dashboards vs. reports?

Use Fast counts for UI dashboards (estimated, metadata-based, thousands of times faster) and Exact counts for critical business logic. This dual-count strategy balances latency and accuracy across different use cases.

Can I perform bulk updates on thousands of records in a single operation?

Bulk operations execute mass create, update, or delete actions in a single highly optimized database call, dramatically reducing execution time and transaction overhead for large-scale data modifications.

When should I use pagination instead of loading all results at once?

Pagination is essential for APIs serving millions of records and high-traffic scenarios. It reduces memory usage, improves response latency, and prevents timeout errors by retrieving data in controlled batches with accurate total counts.

Does Koan Framework handle scaling for back-end services processing large datasets?

Yes. Koan provides proven performance patterns for back-end services, data ingestion pipelines, and administrative dashboards handling millions of records, addressing latency, memory usage, and accurate counting at scale.