fix(logs-page): optimize logs retrieval queries, consolidate useEffects to prevent dup calls#845
Conversation
…nused index, adding new index
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
There was a problem hiding this comment.
Greptile Summary
This PR implements a focused performance optimization for the workflow logs page to address slow loading times. The changes include both database and frontend optimizations:
Database Optimizations:
- Removes two unused indexes (
cost_idxandduration_idx) from theworkflow_execution_logstable that were adding unnecessary overhead during write operations - Adds a new composite index
workflow_started_at_idxon(workflow_id, started_at)columns to support the optimized query pattern - Creates migration files to implement these schema changes
Query Structure Improvement:
The core optimization restructures the logs retrieval query to use join-based filtering instead of WHERE clauses. This allows the database to leverage the new composite index directly during the join operation, rather than performing expensive full table scans with post-filtering.
Frontend Optimizations:
While not visible in the changed files, the PR description indicates consolidation of useEffect hooks to reduce redundant API calls and removal of artificial loading timeouts for more responsive user experience.
This optimization follows established database performance patterns where indexes are aligned with actual query access patterns. The composite index on (workflow_id, started_at) directly supports the common use case of fetching logs for specific workflows ordered by time, which is the primary access pattern for the logs page.
Confidence score: 5/5
- This PR is safe to merge with minimal risk as it contains well-structured database optimizations
- Score reflects straightforward index management changes that follow database best practices
- No files require special attention as the migration is simple and the schema changes are conservative
4 files reviewed, no comments
…ts to prevent dup calls (#845) * fix(logs-page): optimize loading times by improving query, removing unused index, adding new index * add migration files * remove fake min loading time
…ts to prevent dup calls (simstudioai#845) * fix(logs-page): optimize loading times by improving query, removing unused index, adding new index * add migration files * remove fake min loading time
Summary
Type of Change
Testing
Tested loading logs
Checklist