The Brain is the intelligence layer of the DBA Agent. Its role is to build a deep, evolving understanding of the database by jointly reasoning over:
- Schema structure
- Data characteristics
- Query workload
- Explicit human knowledge (rules / hints)
The Brain produces an explainable health score, a semantic ER model, schema classification (Star, Snowflake, etc.), and highly accurate optimization recommendations.
- Explainable by default - no black-box decisions
- Workload-aware - real usage beats theoretical best practices
- Human-in-the-loop - accepts non-obvious domain rules
- Safe & incremental - recommendations before automation
- Continuously learning - schema + workload drift over time
Collected from system catalogs:
- Tables, columns, data types
- Primary keys, foreign keys (explicit)
- Indexes (type, order, cardinality)
- Constraints
- Partitioning
- Row counts and table sizes
- Column cardinality
- NULL ratio
- Data skew (top-N values)
- Histograms (if available)
- Growth rate over time
Normalized from slow logs / stats:
- Query fingerprints
- Frequency
- Avg / P95 latency
- Rows examined vs returned
- Execution plan features (scan type, temp tables, filesort)
Declarative inputs supplied by users to encode domain knowledge that is not inferable from metadata.
Examples:
- "This table is an immutable fact table"
- "This column is a soft foreign key"
- "These tables must always be joined"
- "Do not recommend indexes on this table"
Rules are versioned, scoped, auditable, and treated as high-confidence signals.
Schema Extractor
↓
Schema Graph Builder
↓
Statistics Profiler
↓
Workload Analyzer
↓
Rule Engine
↓
Heuristics Engine
↓
Scoring Engine
↓
Outputs & Recommendations
- Nodes = tables
- Edges = relationships (FKs or inferred joins)
- Edge metadata: direction, cardinality, confidence
The Brain generates ER diagrams that:
- Label fact, dimension, bridge, and lookup tables
- Show cardinality (1:1, 1:N, N:M)
- Distinguish explicit vs inferred foreign keys
- Annotate join frequency from workload
The ER diagram is a semantic artifact, not just a visualization.
Brain classifies the overall schema as:
- Star
- Snowflake
- Hybrid (Star + Snowflake)
- OLTP-style normalized
- Reporting / data-mart
- Anti-pattern (cycles, unclear ownership)
Within the same database, Brain identifies:
- Individual star clusters
- Snowflaked dimensions
- Orphaned tables
- Reporting-only aggregates
Each classification is backed by explainable structural signals (fan-out, depth, cardinality).
For each column, Brain tracks:
- Cardinality & selectivity
- Skew
- NULL ratio
- Join frequency
- Filter frequency
- Group-by / order-by usage
This allows Brain to infer:
- True keys vs accidental keys
- Misused low-cardinality columns
- High-value index candidates
- Partitioning candidates
Queries are normalized to structural fingerprints to aggregate behavior.
Examples:
- Functions on filter columns (e.g. STR_TO_DATE)
- SELECT * in analytical queries
- DISTINCT masking join errors
- JOINs without predicates
- High rows-examined / rows-returned ratio
Query impact is weighted by frequency and latency.
Brain correlates:
- Access patterns from workload
- Existing indexes
- Column cardinalities
It detects:
- Missing indexes
- Incorrect composite index ordering
- Over-indexing
- Unused or redundant indexes
Recommendations are justified with workload evidence.
Brain simulates future states (2×, 5×, 10× data growth) using:
- Current execution plans
- Index depth
- Partition pruning effectiveness
It flags designs that will fail catastrophically under growth.
Brain produces the following scores (0-100):
| Score | Meaning |
|---|---|
| Schema Design Score | Structural soundness |
| --- | --- |
| Query Quality Score | Efficiency & correctness |
| --- | --- |
| Index & Access Score | Workload alignment |
| --- | --- |
| Scalability Score | Future resilience |
| --- | --- |
Brain Score = Weighted aggregate of the above.
Scores are explainable, traceable, and trendable over time.
- Brain Score + sub-scores
- Schema classification summary
- Key risks & anti-patterns
- Prioritized recommendations
- Renderable graph format
- Annotated with semantics and workload signals
- JSON outputs for automation
- Artifacts consumable by dashboards and agents
Brain continuously tracks:
- Schema drift
- Query debt
- Index debt
- Score trends
This enables alerts like:
- "Schema health regressed by 12%"
- "New workload pattern invalidates existing indexes"
The Brain is not a monitoring feature-it is a semantic model of the data layer.
It enables:
- Autonomous DBA actions
- Accurate infra scaling decisions
- Developer-friendly data intelligence
- A strong product moat through explainable reasoning