ardurai/god-skill-suite/god-database-mastery

Claude Code and agent skill by ardurai/god-skill-suite

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

God-level database mastery covering SQL (PostgreSQL deep dive, MySQL differences), NoSQL (MongoDB, Cassandra, DynamoDB), NewSQL (CockroachDB, Spanner), caching (Redis deep dive — data structures, persistence, clustering, pub/sub), message streaming (Apache Kafka — architecture, partitioning, consumer groups, exactly-once semantics), Elasticsearch/OpenSearch (indexing, mapping, search relevance, aggregations), time-series (InfluxDB, TimescaleDB), graph databases (Neo4j), schema design, query optimization, indexing strategies, ACID vs BASE, CAP theorem, replication, sharding, and connection pooling. A developer who does not understand their database is a developer who will eventually bring it to its knees.

Install

npx vskill@latest install ardurai/god-skill-suite/god-database-mastery

SKILL.md

The same SKILL.md was published earlier as ardurai/god-skill-suite/god-database-mastery.

God-Level Database Mastery

Researcher-Warrior Mindset

You do not take the ORM's word for what SQL it generates. You run EXPLAIN ANALYZE. You do not assume the index is being used — you prove it. You read the slow query log. You know that every abstraction leaks, and at some point you will be debugging a production incident with a 3-second database lock hold, and the engineer who understood the query planner will fix it in 10 minutes while the engineer who trusted the ORM sits confused. Know your database at the level of its internals.


Anti-Hallucination Rules

NEVER fabricate:

  • PostgreSQL GUC parameter names — verify against pg_settings or official docs (e.g., max_connections not max_db_connections)
  • Redis command names — ZADD, ZRANGE, GEORADIUS exist; invented commands do not
  • Kafka configuration keys — bootstrap.servers not bootstrap_servers in producer config; verify Java vs Python client differences
  • MongoDB aggregation stage names — $match, $group, $lookup, $unwind, $project are real; invented stages are not
  • Cassandra consistency levels — ALL, QUORUM, LOCAL_QUORUM, ONE, LOCAL_ONE, EACH_QUORUM — verify per operation type
  • CockroachDB/Spanner claimed behaviors — only state what is documented in official sources
  • PgBouncer pool modes — session, transaction, statement — verify behavior of each

ALWAYS verify:

  • PostgreSQL index types available in a given version — BRIN was added in 9.5, covering indexes (INCLUDE) in 11
  • Redis data type command sets — LPOS added in Redis 6.0.6; Bloom Filter requires RedisBloom module
  • Kafka exactly-once semantics versions — idempotent producer GA in 0.11; transactions GA in 0.11; exactly-once consumer in 2.5
  • MySQL vs PostgreSQL syntax differences — UPSERT syntax differs (INSERT ... ON CONFLICT in PG, INSERT ... ON DUPLICATE KEY in MySQL)

1. ACID Properties

Atomicity: A transaction is all-or-nothing. Either all operations succeed and are committed, or none are applied. No partial writes visible to other transactions.

Consistency: A transaction brings the database from one valid state to another. All defined constraints (foreign keys, unique constraints, check constraints) hold after the transaction commits. Note: "Consistency" in ACID is enforced by the application defining valid states, not just the database.

Isolation: Concurrent transactions execute as if they were sequential. The level of isolation is tunable (Read Uncommitted → Read Committed → Repeatable Read → Serializable). Higher isolation = higher contention = lower throughput.

Isolation Level | Dirty Read | Non-Repeatable Read | Phantom Read
----------------------|------------|---------------------|-------------
Read Uncommitted | Possible | Possible | Possible
Read Committed | Prevented | Possible | Possible
Repeatable Read | Prevented | Prevented | Possible
Serializable | Prevented | Prevented | Prevented
PostgreSQL default: Read Committed
MySQL InnoDB default: Repeatable Read
PostgreSQL SSI: true serializable via Serializable Snapshot Isolation

Durability: Once a transaction commits, it survives crashes. Achieved via WAL (Write-Ahead Log) in PostgreSQL — changes are written to the WAL before being applied to data pages, so they can be replayed after a crash.

Cost of ACID: Write amplification (WAL + heap writes), lock contention at high isolation levels, fsync overhead for durability. This is why high-throughput use cases often choose relaxed consistency.

Which databases guarantee full ACID:

  • PostgreSQL: Full ACID, including true Serializable
  • MySQL InnoDB: Full ACID (MyISAM does not)
  • CockroachDB: Distributed ACID (serializable isolation by default)
  • MongoDB: ACID for multi-document transactions since 4.0 (single-document operations are always atomic)
  • Redis: Partial — MULTI/EXEC blocks are atomic but not durable by default without AOF fsync=always

2. BASE

Basically Available: The system guarantees availability (per the CAP theorem interpretation) — responds to every request, possibly with stale or partial data.

Soft State: State may change over time even without input, due to eventual consistency propagation.

Eventually Consistent: Given no new updates, all replicas will converge to the same value — eventually. The window could be milliseconds or seconds depending on the system.

When BASE is acceptable:

  • User profile cache (slightly stale is fine — user doesn't care if their bio update takes 2s to propagate)
  • Product catalog search results (showing yesterday's inventory count is acceptable)
  • Social media timelines (eventual consistency is invisible to users)
  • Analytics counters (exact count vs approximate count is often irrelevant)

When BASE is dangerous:

  • Financial transactions (cannot have two debits from the same account proceed simultaneously)
  • Inventory deduction (two users buying the last item must not both succeed)
  • Authentication (a revoked token must not be accepted on any replica)
  • Medical records (stale data can cause patient harm)

3. CAP Theorem and PACELC

CAP Theorem (Brewer, 2000; formally proven by Gilbert and Lynch, 2002): In the presence of a network partition, a distributed system can provide either Consistency or Availability, but not both simultaneously.

The key insight: Partition tolerance is NOT optional — network partitions happen in any distributed system. The real choice is C or A during a partition.

CP Systems: Prefer consistency over availability during partitions
HBase, Zookeeper, MongoDB (with majority write concern),
CockroachDB, etcd, Consul
AP Systems: Prefer availability over consistency during partitions
Cassandra, DynamoDB (default), CouchDB, Riak,
DNS, many CDNs

PACELC Model (Abadi, 2012) — more practical than CAP:

  • P: If partition: choose A or C (same as CAP)
  • ELC: Else (no partition): choose Latency or Consistency
PACELC classification:
Cassandra: PA/EL — available during partition, low latency normally (tunable)
DynamoDB: PA/EL — available, eventually consistent (tunable per operation)
PostgreSQL: PC/EC — consistent during partition, consistent normally (single-node)
CockroachDB: PC/EC — consistent always (serializable) at latency cost
Spanner: PC/EC — global consistency via TrueTime

4. PostgreSQL Deep Dive

MVCC (Multi-Version Concurrency Control)

PostgreSQL uses MVCC to allow readers and writers not to block each other. Every row has xmin (transaction ID that created it) and xmax (transaction ID that deleted/updated it). A reader sees the version of the row that was committed before the reader's transaction started.

Consequence: VACUUM is mandatory. Dead tuples (rows invisible to all transactions) accumulate. Without VACUUM, tables bloat and pg_clog (transaction status log) fills. autovacuum handles this automatically but must be configured correctly.

sql
-- Monitor vacuum health
SELECT schemaname, tablename,
n_dead_tup, n_live_tup,
last_autovacuum, last_analyze
FROM pg_stat_user_tables
ORDER BY n_dead_tup DESC;
-- Force vacuum on a bloated table
VACUUM ANALYZE my_table;
-- Reclaim space (requires exclusive lock — use with care)
VACUUM FULL my_table;
EXPLAIN ANALYZE Output Reading
sql
EXPLAIN (ANALYZE, BUFFERS, FORMAT TEXT)
SELECT u.id, u.email, o.total
FROM users u
JOIN orders o ON o.user_id = u.id
WHERE u.created_at > '2024-01-01'
AND o.status = 'completed';

Reading the output:

Hash Join (cost=123.45..456.78 rows=1000 width=60)
(actual time=5.123..45.678 rows=892 loops=1)
Buffers: shared hit=245 read=12
-> Seq Scan on orders o (cost=0..234.56 rows=5000 width=20)
(actual time=0.012..12.345 rows=4987 loops=1)
Filter: (status = 'completed')
Rows Removed by Filter: 13013
-> Hash (cost=89.00..89.00 rows=3000 width=40)
(actual time=4.567..4.567 rows=2987 loops=1)
-> Index Scan using users_created_at_idx on users u
(actual time=0.034..3.456 rows=2987 loops=1)
Index Cond: (created_at > '2024-01-01')
Key fields:
cost=X..Y: estimated startup cost .. total cost (in arbitrary units)
actual time=X..Y: measured startup ms .. total ms
rows: actual rows (vs estimated rows — large difference = stale statistics)
Buffers shared hit: pages from buffer cache (fast)
Buffers shared read: pages from disk (slow — if high, add index or more memory)
loops: how many times this node was executed

Red flags:

  • Seq Scan on large table with filter: likely missing index
  • Large difference between estimated and actual rows: run ANALYZE
  • High Rows Removed by Filter: index exists but not selective enough
  • loops > 1 on expensive node: nested loop join on large dataset (consider hash join)
PostgreSQL Index Types
sql
-- B-tree (default): equality and range queries on comparable types
CREATE INDEX idx_orders_created_at ON orders(created_at);
CREATE INDEX idx_users_email ON users(email);
-- Hash: equality only, faster than B-tree for pure equality
-- (B-tree is generally preferred — Hash not WAL-logged in old versions)
CREATE INDEX idx_sessions_token ON sessions USING HASH (token);
-- GiST: geometric types, full-text search (tsvector), range types, geographic
CREATE INDEX idx_locations_geom ON locations USING GIST (location_point);
-- GIN: full-text search (tsvector), JSONB keys, array containment
CREATE INDEX idx_articles_search ON articles USING GIN (to_tsvector('english', content));
CREATE INDEX idx_products_tags ON products USING GIN (tags); -- for array @> queries
CREATE INDEX idx_events_data ON events USING GIN (data jsonb_path_ops); -- for JSONB
-- BRIN (Block Range Index): very large tables with natural physical ordering
-- (e.g., time-series data inserted in order)
-- Tiny index (stores min/max per block range), appropriate when sequential scan is acceptable
CREATE INDEX idx_logs_timestamp_brin ON logs USING BRIN (created_at);
-- Partial index: index only rows matching a condition
CREATE INDEX idx_orders_pending ON orders(created_at) WHERE status = 'pending';
-- Covering index (PostgreSQL 11+): include non-key columns to satisfy queries from index alone
CREATE INDEX idx_users_email_covering ON users(email) INCLUDE (id, name);
Window Functions and CTEs
sql
-- Window function: ranking, running totals, moving averages
SELECT
user_id,
order_total,
SUM(order_total) OVER (PARTITION BY user_id ORDER BY created_at) as running_total,
RANK() OVER (PARTITION BY region ORDER BY order_total DESC) as rank_in_region,
LAG(order_total) OVER (PARTITION BY user_id ORDER BY created_at) as prev_order
FROM orders;
-- CTE: readable complex queries (not always faster — optimizer may or may not inline)
WITH monthly_revenue AS (
SELECT
DATE_TRUNC('month', created_at) as month,
SUM(total) as revenue
FROM orders
WHERE status = 'completed'
GROUP BY 1
),
growth AS (
SELECT
month,
revenue,
LAG(revenue) OVER (ORDER BY month) as prev_revenue,
(revenue - LAG(revenue) OVER (ORDER BY month)) / LAG(revenue) OVER (ORDER BY month) * 100 as growth_pct
FROM monthly_revenue
)
SELECT * FROM growth ORDER BY month;
Connection Pooling with PgBouncer
ini
# pgbouncer.ini — verified configuration keys
[databases]
mydb = host=127.0.0.1 port=5432 dbname=mydb
[pgbouncer]
listen_addr = 0.0.0.0
listen_port = 6432
auth_type = md5
auth_file = /etc/pgbouncer/userlist.txt

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/ardurai/god-skill-suite/god-database-mastery/badge)](https://verified-skill.com/skills/ardurai/god-skill-suite/god-database-mastery)

Something wrong with this skill or its page? Tell us.