From aj-geddes-useful-ai-prompts-4
Implements database sharding strategies including range-based, hash-based, and directory-based partitioning for horizontal scalability across multiple servers.
How this skill is triggered — by the user, by Claude, or both
Slash command
/aj-geddes-useful-ai-prompts-4:database-shardingThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
- [Overview](#overview)
Implement horizontal data partitioning across multiple database servers. Covers sharding strategies, consistent hashing, shard key selection, and cross-shard querying patterns.
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)
);
CREATE TABLE users_shard_1 (
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_1_range CHECK (user_id BETWEEN 1000000 AND 1999999)
);
-- Function to determine shard
CREATE OR REPLACE FUNCTION get_shard_id(p_user_id BIGINT)
RETURNS INT AS $$
BEGIN
// ... (see reference guides for full implementation)
Detailed implementations in the references/ directory:
| Guide | Contents |
|---|---|
| Range-Based Sharding | Range-Based Sharding |
| Hash-Based Sharding | Hash-Based Sharding |
| Directory-Based Sharding | Directory-Based Sharding |
npx claudepluginhub joshuarweaver/cascade-code-languages-misc-1 --plugin aj-geddes-useful-ai-prompts-4Implements PostgreSQL/MySQL sharding with hash, range, directory strategies including routers and shard key selection. Use for horizontal scaling, multi-tenant isolation, billions of records, hotspots, rebalancing, cross-shard queries.
Guides horizontal sharding of PostgreSQL tables across multiple database instances, covering shard key selection, routing strategies, and cross-shard query handling.
Implements horizontal sharding for PostgreSQL, MySQL, MongoDB including shard key selection, data distribution analysis, query routing, and rebalancing.