SQL Batching
Prevents D1/SQLite 'too many SQL variables' errors by automatically batching Drizzle ORM queries with dynamic arrays.
The source repository doesn't declare a license. Check its terms before reusing the code.
Key features
- Provides `autochunk` and `autochunkFirst` utilities for efficient sequential batching
- Manages dynamic arrays in `inArray()` clauses and bulk operations
- Supports parallel query execution using `chunk()` with `Promise.all`
- Automatically chunks queries to stay below the 999 SQL variable limit
- Calculates batch sizes dynamically, accounting for other bound parameters in the query
Use cases
- Querying for a large, dynamically generated list of record IDs
- Performing bulk inserts, updates, or deletes with an unpredictable number of rows
- Fetching data based on unbounded user-generated lists, like team members or event registrations
FAQ
What main capabilities does it provide?
It offers several utilities: `autochunk` for simple sequential batching, `autochunkFirst` for efficiently finding a single record across batches, and a `chunk` helper for running batch queries in parallel with `Promise.all`.
What does the SQL Batching skill do?
This skill automatically splits large Drizzle ORM queries into smaller chunks. This prevents the common 'too many SQL variables' error in databases like D1 and SQLite, which have a limit on bound parameters.
When should I use this Claude Code Skill?
Use this skill whenever your query involves a dynamic or unbounded array. It is essential for `inArray()` clauses, bulk inserts/updates, or any query where the number of variables is unpredictable and could exceed the database limit.
How does this skill improve my workflow?
It saves you from writing complex manual batching logic. This makes your database code cleaner, more resilient, and prevents frustrating runtime errors, allowing you to focus on your application's features instead of database limitations.
Related skills
PostGIS Geospatial Development
Implements best practices for querying and managing geospatial data in PostgreSQL with PostGIS.
Database Management12 ptsSupabase Database Integration
Query and interact with Supabase databases using real-time subscriptions and PostgreSQL-compatible syntax while respecting Row Level Security policies.
Database Management12 ptsDatabase Connection Pooling
Optimizes database performance and reliability by configuring robust connection pools for SQLAlchemy across traditional and serverless architectures.
Database Management12 pts