β All skills
Database Admin
Use when designing database schemas, optimizing queries, managing replication, backups, and high-load operations
About this skill
Use when designing database schemas, optimizing queries, managing replication, backups, and high-load operations
SKILL.md
database-admin.SKILL.mdPlace it in your Syntic skills folder. For Syntic Code, install in your local skills directory, review the contents and run it in a controlled environment first.
---
name: Database Admin
description: Use when designing database schemas, optimizing queries, managing replication, backups, and high-load operations
category: DevOps & Platform
version: 1.0.0
tools: []
---
# Database Admin
Design schemas, optimize queries, ensure data integrity under load for PostgreSQL, MySQL, MongoDB. Think about access patterns before writing schemas.
## Schema Design
- Design around query patterns, not object hierarchies: "how will this data be read?" before "how should it be stored?"
- Normalize to 3NF by default; denormalize deliberately when read performance requires it, documenting tradeoffs
- Every table has primary key: UUIDs (uuid_generate_v4()) for distributed systems, auto-increment for single-database
- Add created_at/updated_at timestamps everywhere, database-level defaults and triggers
- Foreign key constraints enforce referential integrity; disable only if benchmarks prove bottleneck
## PostgreSQL Optimization
- Use EXPLAIN ANALYZE to understand execution plans, look for sequential scans on large tables
- Index columns in WHERE, JOIN, ORDER BY, GROUP BY clauses
- Partial indexes for filtered queries: CREATE INDEX idx_active_users ON users(email) WHERE active = true
- Composite indexes with most selective column first
- pg_stat_statements identifies slow queries; optimize top 10 by total execution time
- Set work_mem appropriately for sorts, monitor with pg_stat_activity
- PgBouncer connection pooling in transaction mode for high-concurrency
## MySQL Optimization
- InnoDB engine exclusively; MyISAM has no place in modern deployments
- EXPLAIN with FORMAT=TREE or FORMAT=JSON for detailed analysis
- InnoDB buffer pool tuned to fit working set in memory (70-80% available RAM)
- Covering indexes satisfy queries entirely from index
- Avoid SELECT *; specify only needed columns
- pt-query-digest from Percona Toolkit analyzes slow query logs
## MongoDB Optimization
- Embed data accessed together, reference independently accessed documents
- Compound indexes matching query predicates and sort orders; index order matters
- Aggregation pipeline for complex transformations, avoid $lookup in hot paths
- readPreference=secondaryPreferred for analytics, offloading primary
- explain("executionStats") verifies index usage, document examination counts
- Shard collections only when single replica set cannot handle write throughput
## Migrations, Replication, Backups
- Migration tools track applied migrations: Flyway, Alembic, Prisma Migrate, golang-migrate
- Migrations reversible: write both up/down scripts
- Never modify applied migrations; create new ones instead
- Expand-contract pattern for zero-downtime: add column, backfill, switch reads, drop old
- Streaming replication (PostgreSQL) or GTID-based (MySQL) for read replicas
- Monitor replication lag; alert when >5-10s baseline
- Automate daily full backups + continuous WAL/binlog archiving
- Store backups in separate region; test restoration monthly
- Retain backups per regulatory requirements (daily 30d, weekly 1y minimum)
## Security
- Separate database users per app with minimum required privileges
- Enable SSL/TLS for all connections; reject unencrypted
- Encrypt data at rest using TDE or filesystem encryption
- Audit access with log analysis; track DDL changes, privilege grants
- Parameterized queries exclusively; never construct SQL from concatenation
Install
Syntic App
- 1Create a dedicated folder for this skill in your local skills library.
- 2Place SKILL.md into that folder.
- 3Restart Syntic and invoke this skill on matching tasks.
Syntic Code (CLI)
- 1Save SKILL.md in your local Syntic Code skills directory.
- 2Keep related files in the same skill folder.
- 3Run in a safe environment and validate outputs.