moai-domain-database

Design schemas, optimize queries, and implement caching across PostgreSQL, MongoDB, Redis, and Oracle.

2|Updated May 27, 2026
One-click install
npx skills add https://github.com/yekinya/moai-novel --skill moai-domain-database-yekinya
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: moai-domain-database
Source: https://github.com/yekinya/moai-novel/tree/main/moai-novel/.claude/skills/moai-domain-database
Command: npx skills add https://github.com/yekinya/moai-novel --skill moai-domain-database-yekinya

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Designing and operating databases across multiple systems requires deep knowledge of each engine's indexing, partitioning, caching, and query optimization patterns, and mistakes like missing indexes or unmanaged connection pools cause production incidents. ## Core Features & Use Cases - Multi-Database Expertise: Covers PostgreSQL schema design and window functions, MongoDB aggregation pipelines, Redis caching and distributed locking, and Oracle PL/SQL with partitioning. - Performance Optimization: Provides EXPLAIN ANALYZE workflows, indexing strategies, materialized views, and multi-layer cache TTL patterns. - Polyglot Persistence: Implements data routing and synchronization patterns that combine relational, document, and in-memory stores. - Use Case: When a user analytics query takes 15 seconds, apply the provided partial indexes and materialized view pattern to reduce it to under 100ms, then add a Redis cache layer for repeated reads. ## Quick Start Ask the assistant to design a PostgreSQL schema with proper indexes and a Redis caching layer for your application's user and order tables.

Frequently Asked Questions about moai-domain-database

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

FAQPage Schema
How do I optimize a slow PostgreSQL query with indexes?

Run EXPLAIN ANALYZE BUFFERS on the slow query to identify full table scans, then create partial or composite indexes matching the WHERE, JOIN, and ORDER BY columns. For repeated analytics, use materialized views refreshed concurrently to cut query time from seconds to milliseconds.

How do I build a MongoDB aggregation pipeline for analytics?

Start with a $match stage backed by an index, then use $group for metrics, $lookup for joins, and $project to shape output. Create compound indexes on filter and sort fields, and enable allowDiskUse for large result sets.

What is the difference between cache-aside and write-through caching in Redis?

Cache-aside checks Redis first and populates it only on a miss, while write-through updates the database and cache together in one operation. Both patterns require explicit cache invalidation on updates to avoid serving stale data.

Does python-oracledb replace cx_Oracle for Oracle connections?

Yes, python-oracledb is the official successor to cx_Oracle and supports async connection pools, statement caching, and batch operations with executemany. It connects to Oracle 19c and 21c and works with SQLAlchemy's Oracle dialect.

Why does my application run out of database connections?

Connection exhaustion happens when pools are undersized or connections leak without being returned. Configure explicit pool_size, max_overflow, pool_pre_ping, and pool_recycle settings, and monitor active connections with pg_stat_activity.

When should I use polyglot persistence instead of a single database?

Use polyglot persistence when different data has different access patterns, such as structured records in PostgreSQL, flexible profiles in MongoDB, and real-time counters in Redis. A DataRouter pattern routes each data type to its appropriate store and synchronizes across them.