ultimate-db
Skill1 starsChanged 8 months agoMITView on GitHub
Database engineering guidance covering schema design, indexing, query optimization, replication, and production operations across relational, document, and columnar stores. Primary focus is PostgreSQL; covers MySQL, MongoDB, ClickHouse, Redis, SQLite, and DuckDB. Use when designing schemas, optimizing slow queries, choosing index types, reviewing migrations, setting up replication, modeling documents, handling VACUUM/MVCC, or when the user mentions SQL, NoSQL, OLAP, EXPLAIN, index bloat, sharding, partitioning, or any named database system.
In this repository33 other files it gives its agents.
- argocdSkill
- c-cpp-compilersSkill
- coding-guidelinesSkill
- devops-iac-engineerSkill
- dag-flowdSkill
- flowd-rules-authorSkill
- frontend-designSkill
- ghSkill
- grafana-dashboardsSkill
- helmSkill
- kustomizeSkill
- legalizerSkill
- lua-projectsSkill
- markdown-documentationSkill
- mermaid-diagramsSkill
- meta-cognition-parallelSkill
- podmasterSkill
- practical-haskellSkill
- rcaSkill
- researcherSkill
- security-auditSkill
- solidity-securitySkill
- svg-genSkill
- tdd-red-green-refactorSkill
- tmux-masterySkill
- tokenomics-designSkill
- ultimate-nixosSkill
- ultimate-rustSkill
- ultimate-web3Skill
- web3-frontendSkill
- web3-testingSkill
- web3-whitepaperSkill
- ziglangSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 3 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 22
Read the relevant reference file before making engine-specific decisions.
- Very specific: line 30
Measure before changing: Use EXPLAIN ANALYZE (SQL), .explain("executionStats") (MongoDB), or the engine equivalent before adding indexes or …
- Distinctive: line 33
Parameterized queries always: No string interpolation into SQL or query builders.
- Distinctive: line 39
Follow ESR order for compound indexes (applies to SQL and MongoDB alike):
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Ultimate Database Engineering
Engine-agnostic principles first. For engine-specific patterns, indexes, and operational details see the reference/ files.
Reference files
| Engine | File | When to read |
| PostgreSQL | reference/postgresql.md | SQL, MVCC, JSONB, FTS, RLS, replication, pooling, extensions |
| MySQL | reference/mysql.md | InnoDB, charset, fulltext, replication |
| MongoDB | reference/mongodb.md | Document modeling, aggregation, Atlas |
| ClickHouse | reference/clickhouse.md | OLAP, MergeTree engines, insert strategy |
| Redis | reference/redis.md | Caching, pub/sub, streams, data structures |
| SQLite | reference/sqlite.md | Embedded, WAL, local-first applications |
| DuckDB | reference/duckdb.md | In-process OLAP, Parquet, analytics |
Read the relevant reference file before making engine-specific decisions. Always check docs for the exact version in use.
Universal principles
These apply regardless of engine, paradigm, or scale:
- Design for access patterns. Model data around the queries you run, not idealized normal form.
- Indexes are the primary performance lever. A missing index on a large table turns milliseconds into seconds.
- Measure before changing. Use
EXPLAIN ANALYZE(SQL),.explain("executionStats")(MongoDB), or the engine equivalent before adding indexes or rewriting queries. - Smallest correct type. Over-provisioned types waste cache, IO, and index space.
- Short transactions. Long-running transactions block vacuuming, lock acquisition, and replication everywhere.
- Parameterized queries always. No string interpolation into SQL or query builders.
- Mutations are expensive in append-optimized engines. In ClickHouse and similar, model to avoid UPDATE/DELETE; prefer reinsert or versioned rows.
- Enforce invariants at the database layer. Constraints, domains, and check constraints catch bugs that application code misses.
Index decision guide
Follow ESR order for compound indexes (applies to SQL and MongoDB alike):
- Equality predicates -- most selective first.
- Sort columns -- eliminates in-memory sort.
- Range predicates -- last.
-- Query: WHERE status = 'active' AND created_at > $1 ORDER BY priority DESC
CREATE INDEX idx_tasks ON tasks (status, priority DESC, created_at);| Scenario | Go-to index type |
| Equality / range / sort (general) | B-tree (all SQL engines) |
| JSONB containment / array overlap | GIN (PostgreSQL) |
| Full-text search | GIN on tsvector (PG) / FULLTEXT (MySQL) / Atlas Search (Mongo) |
| Geospatial | GiST / PostGIS (PG) -- 2dsphere (Mongo) |
| Filtered subset of rows | Partial index (WHERE clause) |
| Avoid heap fetch | Covering index (INCLUDE) |
| Large append-only time-series | BRIN (PG) / ORDER BY date column (ClickHouse) |
| Auto-expiry | TTL index (Mongo) / partition drop (PG, ClickHouse) |
Query anti-patterns (universal)
| Pattern | Fix |
Function on indexed column in WHERE | Use expression index or rewrite the predicate |
OFFSET n pagination on large tables | Keyset / cursor pagination |
SELECT * | Name only the columns needed |
LIKE '%term%' on plain column | Full-text index or trigram index |
| N+1 queries | JOIN, $lookup, or batch IN (...) |
| Implicit type coercion in predicates | Match query type to column type exactly |
| Single-row inserts in batch workloads | Batch 10K+ rows per statement (critical for ClickHouse) |
Schema design checklist
- Timestamps store timezone (
TIMESTAMPTZ,DateTime64('UTC'), ISO 8601). - Monetary values use exact decimal type (
NUMERIC,DECIMAL,Decimal128). - Enumerations use a native enum type or a
CHECKconstraint, not bare strings. - Foreign keys declared and indexed.
- Partitioning chosen for lifecycle (DROP PARTITION), not as index substitute.
- Zero-downtime migration path planned: additive first, backfill, then constrain.
Replication and HA summary
| Engine | Streaming / physical | Logical | Recommended HA tool |
| PostgreSQL | WAL streaming | Publications / subscriptions | Patroni |
| MySQL | Binary log (row-based) | CDC via Debezium | Orchestrator |
| MongoDB | Replica sets (oplog) | Change streams | built-in replica set |
| ClickHouse | ReplicatedMergeTree | -- | ClickHouse Keeper |
| Redis | AOF + RDB snapshots | -- | Redis Sentinel / Cluster |
For configuration details, failover procedures, and monitoring queries see the relevant reference file.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

