Update fetch orders query performance #2304
Conversation
WalkthroughAdds multi-chain and multi-orderbook support to local DB order fetching, expands LocalDbOrder fields, rewrites the SQL to use derived tables and JSON aggregation, consolidates RaindexClient local-DB order retrieval and conversion paths, and updates frontend remote registry/settings URLs. Changes
sequenceDiagram
autonumber
participant Client as RaindexClient
participant Builder as SQL Builder
participant SQL as LocalDB / SQL Engine
participant Parser as IO Parser
participant Conv as Conversion Layer
Client->>Builder: build_fetch_orders_stmt(&FetchOrdersArgs)
Builder->>SQL: execute parameterized SQL (multi-chain, multi-orderbook)
SQL->>SQL: derive latest/first orders (ROW_NUMBER), compute vo/vb/tc/cc, aggregate IO as json_group_array
SQL-->>Client: return Vec<LocalDbOrder>
Client->>Parser: parse_io_vaults(inputs), parse_io_vaults(outputs)
Parser-->>Conv: Vec<LocalDbVault> (inputs/outputs)
Conv->>Client: RaindexOrder::from_local_db_order(local_order, inputs, outputs)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: ASSERTIVE Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (3)crates/**/*.rs📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
**/crates/**📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.rs📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (19)📓 Common learnings📚 Learning: 2025-10-06T11:44:07.888ZApplied to files:
📚 Learning: 2025-10-18T10:38:41.273ZApplied to files:
📚 Learning: 2025-10-06T14:13:18.531ZApplied to files:
📚 Learning: 2025-10-02T19:17:20.332ZApplied to files:
📚 Learning: 2025-10-13T12:57:05.900ZApplied to files:
📚 Learning: 2025-10-06T11:13:29.956ZApplied to files:
📚 Learning: 2025-06-24T08:46:03.368ZApplied to files:
📚 Learning: 2025-05-17T15:32:28.733ZApplied to files:
📚 Learning: 2025-10-06T11:28:30.692ZApplied to files:
📚 Learning: 2025-10-14T07:51:55.148ZApplied to files:
📚 Learning: 2025-05-14T04:49:14.621ZApplied to files:
📚 Learning: 2025-10-21T05:16:07.124ZApplied to files:
📚 Learning: 2025-06-06T16:38:04.182ZApplied to files:
📚 Learning: 2025-04-30T09:28:36.960ZApplied to files:
📚 Learning: 2025-08-01T09:07:20.383ZApplied to files:
📚 Learning: 2025-05-19T13:40:56.080ZApplied to files:
📚 Learning: 2025-05-14T05:13:59.713ZApplied to files:
📚 Learning: 2025-06-24T13:30:02.968ZApplied to files:
🧬 Code graph analysis (1)crates/common/src/raindex_client/local_db/mod.rs (3)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (1)
Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
| chain_ids.sort_unstable(); | ||
| chain_ids.dedup(); | ||
|
|
||
| // Orderbook addresses (lowercase, deduplicated) |
There was a problem hiding this comment.
It's a list of addresses so inaccurate comment
There was a problem hiding this comment.
As in they can't be lowercase or uppercase
| let args = FetchOrdersArgs { | ||
| chain_ids: vec![1], | ||
| orderbook_addresses: vec![ | ||
| Address::from_str("0xAbCDeF0000000000000000000000000000000000").unwrap(), |
There was a problem hiding this comment.
Why not the address! macro?
|
@coderabbitai assess this PR size classification for the totality of the PR with the following criterias and report it in your comment: S/M/L PR Classification Guidelines:This guide helps classify merged pull requests by effort and complexity rather than just line count. The goal is to assess the difficulty and scope of changes after they have been completed. Small (S)Characteristics:
Review Effort: Would have taken 5-10 minutes Examples:
Medium (M)Characteristics:
Review Effort: Would have taken 15-30 minutes Examples:
Large (L)Characteristics:
Review Effort: Would have taken 45+ minutes Examples:
Additional Factors to ConsiderWhen deciding between sizes, also consider:
Notes:
|
|
Tip For best results, initiate chat on the files or code changes. SIZE=L 🧠 Learnings used |
Motivation
Previous fetch orders query was doing a lot of I/O and wasm-to-js interactions and because of that the response time was not that good. This PR aims to improve performance by reducing the number of queries that need to be made and only introduce a single query
Solution
Checks
By submitting this for review, I'm confirming I've done the following:
Summary by CodeRabbit
New Features
Bug Fixes
Chores
✏️ Tip: You can customize this high-level summary in your review settings.