Skip to content
Back to skills

Yugabytedb Schema Design

ASecurity

Best practices for designing high-performance YugabyteDB schemas from scratch or optimizing existing ones. Covers hash vs range sharding decisions, avoiding write hotspots on sequential columns, partial indexes for nullable or skewed columns, low-cardinality index design, covering indexes, primary key selection, foreign key index requirements, and redundant index cleanup. Use this skill whenever the user asks how to design a YugabyteDB schema, choose a sharding strategy, avoid hotspots, optim...

  • 3 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 2, 2026
ai-agentsgosqldatabaseperformance

Security analysis

A100/100

Pro scans all 9 files and shows the line behind each finding

Scanned October 2, 2026

npx -y skills add srinivasa-vasu/agent-skills --skill yugabytedb-schema-design --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Yugabytedb Schema Design?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Yugabytedb Schema Design
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/srinivasa-vasu-yugabytedb-schema-design/badge)](https://www.skillsdirectory.com/skills/srinivasa-vasu-yugabytedb-schema-design)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: yugabytedb-schema-design
description: >
  Best practices for designing high-performance YugabyteDB schemas from scratch or optimizing
  existing ones. Covers hash vs range sharding decisions, avoiding write hotspots on sequential
  columns, partial indexes for nullable or skewed columns, low-cardinality index design, covering
  indexes, primary key selection, foreign key index requirements, and redundant index cleanup.
  Use this skill whenever the user asks how to design a YugabyteDB schema, choose a sharding
  strategy, avoid hotspots, optimize indexes, handle NULL-heavy columns, model a table for
  distributed SQL, or asks "how should I structure this in YugabyteDB". Trigger even when the
  user mentions "YugabyteDB indexes", "YSQL schema", "tablet hotspot", "sharding key", or asks
  why their YugabyteDB writes are slow or skewed.
---

# YugabyteDB Schema Design Best Practices

This skill covers **how to design schemas well** for YugabyteDB. The design patterns that make a schema performant in a distributed SQL environment.

## Core Concepts (Read First)

YugabyteDB is an index-organized, distributed SQL database. Every design decision flows from
three foundational facts:

1. **The primary key IS the table.** Rows are stored sorted by PK. No PK = system assigns `ybrowid` (hidden, hash-sharded).
2. **Default sharding is HASH.** Data is distributed by hashing the sharding key across tablets. Great for point lookups, bad for range queries.
3. **Tablets split automatically, but hotspots happen.** Sequential values (timestamps, auto-increment IDs) written to a range-sharded index concentrate all writes on one tablet until it splits.

## Reference Files

Read only the section(s) relevant to the user's question:

- `references/sharding.md` — Hash vs range, when to use each, choosing a sharding key
- `references/hotspots.md` — Preventing write/read hotspots on timestamps and monotonic PKs
- `references/index-design.md` — Index column ordering, covering indexes, redundant indexes
- `references/partial-indexes.md` — Partial indexes for NULL-heavy and skewed-value columns
- `references/low-cardinality.md` — Avoiding poor distribution from boolean/ENUM/low-distinct sharding keys
- `references/primary-keys.md` — PK selection, explicit PKs, composite PKs for partitioned tables
- `references/foreign-keys.md` — FK type alignment, mandatory FK indexes

## Quick Decision Guide

| User's question | Go to |
|---|---|
| "Should I use hash or range sharding?" | `sharding.md` |
| "My timestamp writes are all going to one tablet" | `hotspots.md` |
| "How do I index this column?" | `index-design.md` |
| "Half my rows have NULL in this column" | `partial-indexes.md` |
| "Indexing a status/boolean column" | `low-cardinality.md` |
| "What should my primary key be?" | `primary-keys.md` |
| "FK performance is slow" | `foreign-keys.md` |
| "Can you design schema for this?" | `Refer all the files for the optimal design` |
| "Can you optimize this schema?" | `Refer all the files for the optimal design` |

## Golden Rules at a Glance

```
✅ Always define an explicit PRIMARY KEY
✅ Use ASC/DESC on index columns that are range-queried
✅ Put high-cardinality columns first in multi-column indexes
✅ Index every foreign key column in child tables
✅ Use partial indexes for nullable or skewed columns
✅ Match FK column types exactly (INT vs BIGINT matters)
✅ Drop redundant indexes (prefix-covered by another index)
✅ Use text datatype whereever possible instead of VARCHAR(n)

❌ Never use a low-cardinality column as the sole sharding key
❌ Never range-shard on a monotonically increasing column without a synthetic shard key
❌ Never leave tables without a PK if UNIQUE NOT NULL columns exist
❌ Never create multi-column GIN indexes
```

Files in this skill

  • README.md3.3 KB
  • SKILL.md3.7 KB
  • references/foreign-keys.md4.9 KB
  • references/hotspots.md6.9 KB
  • references/index-design.md4.1 KB
  • references/low-cardinality.md4.4 KB
  • references/partial-indexes.md4.4 KB
  • references/primary-keys.md4.4 KB
  • references/sharding.md3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…