Optimize DirectionsRatesJob: batch INSERT instead of individual queries#66
Merged
Optimize DirectionsRatesJob: batch INSERT instead of individual queries#66
Conversation
Author
Code reviewFound 1 issue:
The PR migrated all workers to jobs (e.g., Lines 23 to 28 in 8b9309d Lines 23-28 reference Lines 103 to 104 in 8b9309d Line 103 references 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
Replace individual create! calls with single insert_all! for significant performance improvement when processing large numbers of exchange rates. - Add Mathematic module for calculate_finite_rate - Cache currency_rates by currency_pair for O(1) lookup - Build all records in memory, then insert in one SQL statement - Handle missing currency_rates gracefully (skip instead of error) Fixes #64 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Add explicit order(:interval_from) before .last to utilize the composite index (cur_from_id, cur_to_id, interval_from) instead of falling back to ORDER BY id DESC which requires a full table scan. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Rename "Worker Architecture" to "Job Architecture (ActiveJob/SolidQueue)" - Update all class references from *Worker to *Job - Update File Organization: app/workers/gera/ → app/jobs/gera/ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
759d2cf to
5f73dc1
Compare
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
insert_all!callChanges
Mathematicmodule forcalculate_finite_ratemethodPerformance Impact
Test plan
Fixes #64
🤖 Generated with Claude Code