feat(schema): schema insights advisor (issue #6 scope A)#93
Merged
Conversation
Add SchemaAdvisor service producing four non-index schema insights alongside the existing index recommender: - FK fan-out: one-to-many JOIN without aggregation/DISTINCT - Nullable FK: nullable FK column in a JOIN drops orphan rows - Low cardinality: WHERE/JOIN on a low-NDV column (poor selectivity) - Stale stats: planner stats old (>=14d) or never gathered Backend coverage degrades gracefully to "skipped" rather than erroring: PostgreSQL full (pg_stats.n_distinct, pg_stat_user_tables.last_analyze), MySQL partial (STATISTICS.CARDINALITY, innodb_table_stats.last_update), SQLite FK insights only. Extends DatabaseIntrospector with NDV + stats-freshness fetchers, bumps the live schema snapshot cache to v2, adds QueryAnalysis.schema_insights (migration 0007), wires a guarded advisor call into the grade view (failure never blocks the grade), and renders a Schema insights panel in grade_results.html with dark-mode severity pills. Adds 20 tests (17 unit covering every insight's positive/negative/skipped path, 3 e2e). Full analyzer suite green.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements sub-scope A (broader non-index schema analysis) of #6. PR #54 delivered the index-recommendation slice; this adds a
SchemaAdvisorservice producing four structural/statistical insights, displayed in a new "Schema insights" panel parallel to the index panel.Insights
Backend coverage
Degrades gracefully to
skipped(never errors):pg_stats.n_distinct,pg_stat_user_tables.last_analyzeSTATISTICS.CARDINALITY,innodb_table_stats.last_update(the real stats-refresh time, not the invertedupdate_timeproxy)Changes
DatabaseIntrospector: NDV + stats-freshness fetchersLiveSchemaContext: snapshot cache bump v1→v2,last_analyzed+ per-columnndvQueryAnalysis.schema_insightsJSONField + migration0007grade_results.htmlpanel + dark-mode severity pillsPlacement
Mirrors the existing index panel exactly — both render on
grade_results.html(reached via history "View full analysis"). No change toenhanced_grade_results.html.Test plan
analyzersuite green (720 tests, 0 fail/err, 14 skip)Relates to #6