
Database Sharding
This handles horizontal database partitioning when you've outgrown a single server or need geographic distribution. It covers the main sharding strategies: range-based (split by ID ranges), hash-based (distribute via consistent hashing), and directory-based (lookup table routing). You get practical SQL examples for defining shards with constraint checks and routing logic. The approach is solid for multi-tenant isolation or when read/write throughput becomes your bottleneck. One thing to note is that cross-shard queries get messy fast, so pick your shard key carefully upfront. The reference guides break down each strategy separately, which helps when you're trying to decide between them based on your access patterns.
- skills.sh installs
- 446
- GitHub stars
- 379
- last updated
- Aug 21, 2026
Install
$ npx -y skills add aj-geddes/useful-ai-prompts --skill database-sharding --agent claude-codeInstalls into .claude/skills of the current project.
Files
Database Sharding
Table of Contents
Overview
Implement horizontal data partitioning across multiple database servers. Covers sharding strategies, consistent hashing, shard key selection, and cross-shard querying patterns.
When to Use
- Database size exceeds single server capacity
- Read/write throughput needs horizontal scaling
- Geographic data distribution requirements
- Multi-tenant data isolation
- Cost optimization through distributed architecture
- Load balancing across database instances
Quick Start
Minimal working example:
-- Define shard ranges
-- Shard 0: user_id 0-999999
-- Shard 1: user_id 1000000-1999999
-- Shard 2: user_id 2000000-2999999
CREATE TABLE users_shard_0 (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id BIGINT NOT NULL,
email VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT NOW(),
CONSTRAINT shard_0_range CHECK (user_id BETWEEN 0 AND 999999)
);
Sponsors
Details
- Repository
- github.com/aj-geddes/useful-ai-prompts
- Categories
- Backend & APIs, AI & Agent Building, Databases
- First seen
- Jun 3, 2026
More from aj-geddes/useful-ai-prompts
All 258- Network Security Groups446
- Azure App Service445
- Feature Flag System445
- Infrastructure Cost Optimization445
- Capacity Planning444
- Container Registry Management444
- Third Party Integration443
- Continuous Testing441
- Dependency Tracking440
- Artifact Management439
- Graceful Shutdown439
- Blue Green Deployment437
- Disaster Recovery Testing437
- Release Planning436
- Intermittent Issue Debugging433
- Server Side Rendering433
- Mocking Stubbing432
- Data Migration Scripts430
- Correlation Tracing429
- Synthetic Monitoring427
- Canary Deployment426
- Service Mesh Implementation426
- Azure Functions424
- Data Replication Setup424