Skip to content

fix(logs-page): optimize logs retrieval queries, consolidate useEffects to prevent dup calls#845

Merged
icecrasher321 merged 3 commits intostagingfrom
fix/logs-loading-times
Aug 1, 2025
Merged

fix(logs-page): optimize logs retrieval queries, consolidate useEffects to prevent dup calls#845
icecrasher321 merged 3 commits intostagingfrom
fix/logs-loading-times

Conversation

@icecrasher321
Copy link
Collaborator

@icecrasher321 icecrasher321 commented Aug 1, 2025

Summary

  • Permissions join was taking a while. Rearranged query to not have where class but filter as part of join to actually use index.
  • Also removed two unused indices.
  • Consolidated useEffects to make one less fetch logs call
  • Remove artificial minLoadingTime timeout

Type of Change

  • Other: Performance Improvement

Testing

Tested loading logs

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Aug 1, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sim 🔄 Building (Inspect) Visit Preview 💬 Add feedback Aug 1, 2025 11:22pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
docs ⬜️ Skipped (Inspect) Aug 1, 2025 11:22pm

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_idx and duration_idx) from the workflow_execution_logs table that were adding unnecessary overhead during write operations
  • Adds a new composite index workflow_started_at_idx on (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

Edit Code Review Bot Settings | Greptile

@icecrasher321 icecrasher321 changed the title fix(logs-page): optimize logs retrieval queries fix(logs-page): optimize logs retrieval queries, consolidate useEffects to prevent dup calls Aug 1, 2025
@icecrasher321 icecrasher321 merged commit 545ec79 into staging Aug 1, 2025
4 of 5 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/logs-loading-times branch August 2, 2025 22:17
waleedlatif1 pushed a commit that referenced this pull request Aug 5, 2025
…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
arenadeveloper02 pushed a commit to arenadeveloper02/p2-sim that referenced this pull request Sep 19, 2025
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant