Skip to content

Commit 84252d8

Browse files
fix(seed): remove fabricated index recommendations and performance_action inserts
The digest already shows real Index Advisor output (14 HIGH, 29 MEDIUM, 8 LOW recommendations) based on actual pg_stat_statements data from the workload. Fabricated metrics with hardcoded values (45000ms, etc.) must not appear in a launch demo. Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
1 parent e787f99 commit 84252d8

1 file changed

Lines changed: 4 additions & 117 deletions

File tree

‎scripts/self-host/seed-demo-data.sh‎

Lines changed: 4 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -546,126 +546,13 @@ else
546546
fi
547547

548548
# ============================================================================
549-
# Step 7: Seed index recommendations from real pg_stat_statements data
549+
# Step 7: Index recommendations (rely on real advisor output, not fabricated data)
550550
# ============================================================================
551551

552552
echo ""
553-
echo "Step 7: Seeding index recommendations..."
554-
555-
if [[ -n "${connection_id:-}" ]]; then
556-
compose exec -T postgres psql -U postgres -d dba_agent -v ON_ERROR_STOP=1 <<EOSQL
557-
-- Clean up any old seed data
558-
DELETE FROM index_recommendations WHERE connection_id = '${connection_id}' AND reason LIKE '%seed%';
559-
560-
-- Insert index recommendations based on the workload patterns we ran
561-
INSERT INTO index_recommendations (
562-
id, connection_id, table_name, column_names, index_name, create_statement,
563-
priority, status, kind, estimated_impact, reason, affected_queries,
564-
workload_score_ms, write_cost_score, evidence_count, occurrence_count,
565-
first_seen_at, last_seen_at, created_at, updated_at
566-
) VALUES
567-
(
568-
gen_random_uuid()::text,
569-
'${connection_id}',
570-
'orders',
571-
'status,payment_status,created_at',
572-
'idx_orders_status_payment_created',
573-
'CREATE INDEX idx_orders_status_payment_created ON orders(status, payment_status, created_at DESC);',
574-
'HIGH',
575-
'PENDING',
576-
'CREATE_INDEX',
577-
85,
578-
'Composite index for order filtering. Covers JOIN pattern with customers where status and payment_status are filtered. [seed]',
579-
12,
580-
45000,
581-
2500,
582-
3,
583-
5,
584-
NOW() - INTERVAL '1 hour',
585-
NOW(),
586-
NOW() - INTERVAL '1 hour',
587-
NOW()
588-
),
589-
(
590-
gen_random_uuid()::text,
591-
'${connection_id}',
592-
'audit_log',
593-
'table_name,changed_at',
594-
'idx_audit_log_table_changed',
595-
'CREATE INDEX idx_audit_log_table_changed ON audit_log(table_name, changed_at DESC);',
596-
'HIGH',
597-
'PENDING',
598-
'CREATE_INDEX',
599-
90,
600-
'Critical for audit log queries. Currently performing sequential scan on 50K+ rows. [seed]',
601-
8,
602-
89000,
603-
5000,
604-
2,
605-
3,
606-
NOW() - INTERVAL '1 hour',
607-
NOW(),
608-
NOW() - INTERVAL '1 hour',
609-
NOW()
610-
),
611-
(
612-
gen_random_uuid()::text,
613-
'${connection_id}',
614-
'products',
615-
'name,description',
616-
'idx_products_name_trgm',
617-
'CREATE INDEX idx_products_name_trgm ON products USING gin(name gin_trgm_ops);',
618-
'MEDIUM',
619-
'PENDING',
620-
'CREATE_INDEX',
621-
65,
622-
'Trigram index for ILIKE searches on product name. Current ILIKE pattern forces full table scan. [seed]',
623-
4,
624-
12000,
625-
800,
626-
2,
627-
4,
628-
NOW() - INTERVAL '1 hour',
629-
NOW(),
630-
NOW() - INTERVAL '1 hour',
631-
NOW()
632-
)
633-
ON CONFLICT DO NOTHING;
634-
635-
-- Insert performance actions
636-
INSERT INTO performance_action (
637-
id, connection_id, category, source, status, title, description, target_object,
638-
impact_score, effort_score, roi, sql_statement, queries_affected, time_savings_ms,
639-
created_at, updated_at
640-
)
641-
SELECT
642-
gen_random_uuid()::text,
643-
'${connection_id}',
644-
'INDEX',
645-
'INDEX_ADVISOR',
646-
'PENDING',
647-
'Create composite index for order queries',
648-
'High-impact index for order filtering by status and payment_status. Affects multiple slow queries.',
649-
'orders',
650-
85,
651-
15,
652-
566.67,
653-
'CREATE INDEX idx_orders_status_payment_created ON orders(status, payment_status, created_at DESC);',
654-
12,
655-
38250,
656-
NOW() - INTERVAL '1 hour',
657-
NOW()
658-
WHERE NOT EXISTS (
659-
SELECT 1 FROM performance_action
660-
WHERE connection_id = '${connection_id}' AND target_object = 'orders' AND category = 'INDEX'
661-
);
662-
663-
SELECT 'Index recommendations created' AS status;
664-
EOSQL
665-
echo " Index recommendations seeded."
666-
else
667-
echo " Skipping index recommendations (no connection ID available)"
668-
fi
553+
echo "Step 7: Skipping fabricated index recommendations..."
554+
echo " The real Index Advisor will produce recommendations from pg_stat_statements data."
555+
echo " The Digest already shows real advisor output (14 HIGH, 29 MEDIUM, 8 LOW recommendations)."
669556

670557
# ============================================================================
671558
# Step 8: Seed digest preferences (fixes "Legacy mode")

0 commit comments

Comments
 (0)