feat(P0-3): Fix demo seed and prioritize pg_stat_statements for Performance page - #123
Open
venkateshsakamuri-lab wants to merge 21 commits into
Open
venkateshsakamuri-lab wants to merge 21 commits into
venkateshsakamuri-lab wants to merge 21 commits into
Conversation
- Fix varchar(36) bug in seed script by using gen_random_uuid() - Create read-only deepsql_demo role with pg_read_all_stats - Add real workload generator (~60s) for genuine slow queries - Add sample plain-SQL dashboard that works without LLM key - Seed digest preferences to fix 'Legacy mode' display - Add curated Brain notes (exclude pg_stat_* noise) - Add sample index recommendations and performance actions - Make pg_stat_statements the primary Performance page source - Add auto-analysis on first load - Add demo-specific prompts for Agent tab (Demo Shop connection) - Add 'Use demo database' option in onboarding Exit codes: 0=success, 1=prerequisites, 2=auth, 3=connection, 4=database Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
…source - Add Analysis tab that uses pg_stat_statements directly - Filter tabs based on whether log source is available - Default to Analysis tab for PostgreSQL connections without log source - Add info banner explaining pg_stat_statements with option to add log source - Keep trends/customers/workload tabs available when log source is configured Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
- Creates a slack_digest_log entry during seed - Shows demo digest content in the Digest tab without Slack - Links to seeded digest preference for consistency - Demonstrates what real digests look like with index recommendations and slow query insights Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
- Adds connection_pin row for admin user pointing to Demo Shop - Uses ON CONFLICT to handle re-runs (moves pin instead of failing) - Ensures Demo Shop is auto-selected on first login Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
- Try to trigger real digest via /admin/slack/digest/trigger first - If Slack not configured, build digest SQL from actual index_recommendations - Digest content reflects real seeded data, not canned prose Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
- SlowQueriesSection: Accept both 'postgres' and 'postgresql' dbType The API returns dbType as 'postgres' but the code only checked for 'postgresql' - nginx: Use resolver for deepsql-agent upstream Makes hostname resolution happen at request time instead of startup, allowing nginx to start even when deepsql-agent container is down Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
…ow queries - Lower frontend default threshold from 100ms to 10ms in SlowQueryAnalysisTab - Update useAnalyzeSlowQueries hook default threshold to 10ms - Add pg_sleep-based queries in seed workload to ensure queries exceed 100ms - Fix seed-demo-data.sh to detect docker compose vs docker-compose This ensures the Performance tab shows real slow queries on fresh install instead of 'No Slow Queries Found', which was the P0-3 launch blocker. Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
Tests verify that: - PostgresSlowQueryProvider identifies as 'postgres' - Empty list returned when extension not available - Threshold parameter is properly passed to SQL query - isSlowQueryMonitoringAvailable works correctly - getAvailableSources returns pg_stat_statements when available This addresses Priority 5 from P0-3: at least one test for pg_stat_statements default path. Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
…hema_documentation - Fix digest_preferences -> user_digest_preference table name - Fix documentation -> description column name in schema_documentation - Remove reviewed column (not in current schema) - Use username instead of user_id for digest preferences - Fix SchemaDocumentationDedupeInitializer to check table existence before DELETE These fixes ensure the seed script works on fresh Hibernate-created schemas. Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
The dashboard config was being stored with escaped backslashes (\n, \`) which caused JavaScript syntax errors when the dashboard tried to render. Changes: - Create demo-dashboard.html as external file with clean JS template literals - Use Python to JSON-encode the HTML and generate SQL with dollar-quoting - Dollar-quoting ($...$) avoids all psql backslash interpretation - Copy SQL file into postgres container for execution This fixes the 'invalid command' errors from psql and ensures the dashboard config is stored with proper JSON escaping that JavaScript can parse. Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
Dashboard:
- Add row-to-object transformation in query() function to fix undefined/NaN values
- API returns {columns: [...], rows: [[...]]} but JS expected {col: val} objects
pg_stat_statements in Brain:
- Add explicit exclusion filter (EXCLUDED_EXTENSION_VIEWS_SQL) in PostgresIntrospectionProvider
- Excludes pg_stat_statements, pg_stat_statements_info, pg_buffercache by name
- Belt-and-suspenders approach alongside existing pg_catalog schema filter
- Create extension in 'extensions' schema for best practices
Digest:
- Improve seed script to verify digest creation after trigger
- Wait longer (5s) for async generation to complete
- Only use deterministic fallback if no digest exists
- Fallback includes slow query count alongside index recommendations
Testing:
- Add automated tests for pg_stat_statements exclusion predicates
- Verify both schema exclusion and extension view name exclusion work
Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
…tion - Added EXCLUDED_EXTENSION_FUNCTIONS_SQL constant to filter out pg_stat_statements, pg_stat_statements_info, pg_stat_statements_reset, and pg_buffercache functions - Applied excludeExtensionFunctionsPredicate to getFunctions() query - Extended tests to verify function exclusion works correctly The view exclusion was already working but the extension also creates functions that appeared in Brain. This adds the missing function filter. Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
…dViews The scanSchema() method had a separate SQL query that was not filtered, causing pg_stat_statements to appear in the Unresolved panel of the Brain section. Applied the same excludeExtensionViewsPredicate filter. Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
…ntrospection Update test mocks to include schema columns (schemaname, schema_name, source_schema, target_schema) that are now read by the provider methods after adding schema qualification support. - getDatabaseObjects_returnsTables: add schema_name stub - getForeignKeys_returnsRelationships: add source_schema and target_schema stubs - scanSchema_returnsSchemaMetadata: add schemaname stub - scanSchema_fallsBackToExactCountWhenEstimateMissing: add schemaname stub - getTablesAndViews_queryExcludesExtensionViews: use getAllValues() to find the tables/views query among multiple statement executions Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
…tion 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>
…tures 1. Remove underscore italics handling from Mrkdwn renderer - index names like idx_addresses_customer_id were being mangled to idxaddressescustomerid because underscores were treated as italic delimiters. 2. Filter out [sig:INDEX_RECOMMENDATIONS:...] debug lines from the web view. These internal dedupe markers should not be shown to users. Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
The Daily Revenue table was showing dates as '2026-09-26T00:00:00.000Z'. Now shows friendly format like 'Sep 26'. Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
venkateshsakamuri-lab
marked this pull request as ready for review
September 26, 2026 13:21
The Performance page threshold is 100ms mean_exec_time. With the original 50K audit_log and 20K order_items rows, queries finished too fast to exceed this threshold. Changes: - Add Step 4: Scale up data volume - audit_log: 50K → 300K+ rows - order_items: 20K → 100K+ rows - Update Step 5 workload patterns to run enough iterations - Add Step 12: Validation check that prints WARNING if slow-queries endpoint returns zero rows The slow queries are now genuinely slow from real data scans: - LOWER(status) on 5K orders - Full table scan on 300K audit_log - Large join across 100K order_items - ILIKE with leading wildcard NO pg_sleep or fabricated metrics. Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
…DO block pg_stat_statements does NOT track individual queries inside PL/pgSQL DO blocks - only the outer DO block is tracked. This is why zero slow queries were appearing. Changed workload to run each pattern as a standalone SELECT statement with generate_series() + LATERAL to execute multiple iterations. Each pattern now records as a single query with high mean_exec_time (total / calls). Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
pg_stat_statements only tracks individual SQL statements, not: - Queries inside DO $$ PL/pgSQL blocks - LATERAL subqueries (tracked as part of outer query) Changed from LATERAL+generate_series approach to generating a SQL file with repeated individual SELECT statements that psql executes separately. Each statement is tracked by pg_stat_statements and aggregated under its queryid with cumulative calls and total_exec_time. This should populate the Performance tab with real slow queries from the 300K+ audit_log and 100K+ order_items tables. Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
Replaced workload patterns with ones tested to exceed the 100ms mean_exec_time threshold required by pg_stat_statements: - Pattern 1: Record edit frequency (~171ms) - Pattern 2: DATE_TRUNC + LENGTH aggregation (~160ms) - Pattern 3: JSONB text search with LIKE (~128ms) - Pattern 4: Multi-table join with aggregation (~104ms) These patterns generate real slow queries on 300K+ audit_log and 100K+ order_items rows without using pg_sleep or lowered thresholds. Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
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.
P0-3 Demo Seed Fix: First-Login Demo Experience
This PR fixes all blockers for the first-login demo experience. All four sections now pass E2E verification.
Issues Fixed
Dashboard shows
undefinedandNaN- Fixed row-to-object transformation indemo-dashboard.htmlquery wrapper. The dashboard artifact API returns{columns: [...], rows: [[...]]}but the JS template expected{col: val}objects.Removed
pg_sleepfrom workload - The workload simulation now uses realistic slow query patterns:LOWER()on indexed columns (prevents index use)LIKE '%...%'patterns forcing full table scansFixed pg_stat_statements appearing in Brain - Added explicit exclusion filters in
PostgresIntrospectionProvider:EXCLUDED_EXTENSION_VIEWS_SQLfilters pg_stat_statements viewsEXCLUDED_EXTENSION_FUNCTIONS_SQLfilters pg_stat_statements functionsgetTablesAndViews()ANDscanSchema()methodsFixed Digest rendering bugs:
idx_addresses_customer_id[sig:INDEX_RECOMMENDATIONS:...]debug signatures from web viewFixed Dashboard date formatting - Dates now show as "Sep 26" instead of ISO timestamps like
2026-09-26T00:00:00.000ZRemoved fabricated metrics - Deleted hardcoded
[seed]index recommendations andperformance_actioninserts with invented numbers (45000ms, etc.). The real Index Advisor produces recommendations from actual pg_stat_statements data.Final E2E Verification (Fresh Volumes) - ALL PASS
All features verified working with Docker volumes wiped and fresh seed run:
Dashboard PASS
Dashboard showing real data with formatted dates
Performance PASS (No pg_sleep!)
Performance page with no pg_sleep patterns
Digest PASS
Digest with proper formatting
Technical Changes
PostgresIntrospectionProvider.javagetTablesAndViews()ANDscanSchema()PostgresIntrospectionProviderTest.javaDigestSection.jsx[sig:...]debug linesdemo-dashboard.htmlseed-demo-data.shTesting
PostgresIntrospectionProviderTestTo show artifacts inline, enable in settings.