neki

Audits PostgreSQL schema and query patterns for future sharding readiness and needed changes.

Updated May 17, 2022
One-click install
npx skills add https://github.com/kanade0404/dotfiles --skill neki-kanade0404
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: neki
Source: https://github.com/kanade0404/dotfiles/tree/main/.opencode/skills/neki
Command: npx skills add https://github.com/kanade0404/dotfiles --skill neki-kanade0404

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps teams prepare PostgreSQL systems for future horizontal sharding by highlighting schema, query, and transaction patterns that would otherwise cause expensive rework later.

Core Features & Use Cases

  • Shard-Key Planning: Choose and propagate a stable shard key across tenant-scoped tables before scaling pressure forces a redesign.
  • Schema and Query Review: Check primary keys, indexes, joins, foreign keys, and filters so common queries stay shard-local instead of scattering across shards.
  • Operational Readiness: Identify when to use mapping tables, app-level enforcement, rollups, and migration patterns that fit a sharded architecture.
  • Use Case: A growing SaaS app can review its users, orders, and order_items tables now to ensure the data model will still work when it needs to split across shards.

Quick Start

Ask this Skill to review your PostgreSQL schema and query patterns for sharding readiness and summarize the changes needed to keep data shard-local.

Frequently Asked Questions about neki

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

FAQPage Schema
How do I prepare a PostgreSQL schema for future sharding?

To prepare a PostgreSQL schema for sharding, you must propagate a stable shard key across tenant-scoped tables and use composite primary keys. This ensures data remains shard-local and avoids expensive rework later.

What is a shard-leading index and how does it avoid scatter-gather queries?

A shard-leading index prefixes standard indexes with the shard key to keep common queries shard-local. This routing pattern avoids scatter-gather operations by ensuring queries target a single shard instead of scanning all shards.

Can I use foreign keys in a multi-tenant PostgreSQL database without breaking sharding?

Yes, you can use foreign keys in a multi-tenant PostgreSQL database if they remain strictly shard-local. You must apply scoped uniqueness and shard-key propagation to ensure transaction patterns and joins do not cross shard boundaries.

When do I need mapping tables or app-level enforcement for database scaling?

You need mapping tables and app-level enforcement for database scaling when standard database constraints cannot remain shard-local. These patterns handle cross-shard relationships and unique constraints that a sharded architecture cannot enforce natively.

What are the limitations of preparing an existing PostgreSQL schema for horizontal sharding?

The main limitation of preparing an existing PostgreSQL schema for horizontal sharding is the extensive rework required if shard keys were not propagated initially. You must redesign primary keys, indexes, and co-located joins to prevent scatter-gather operations.