Skip to content

Tighter filter on all solvable orders query#4131

Merged
MartinquaXD merged 4 commits intomainfrom
tighter-filter-on-all-solvable-orders-query
Feb 6, 2026
Merged

Tighter filter on all solvable orders query#4131
MartinquaXD merged 4 commits intomainfrom
tighter-filter-on-all-solvable-orders-query

Conversation

@MartinquaXD
Copy link
Contributor

Description

Forgot that I already hit merge when ready on #4129 so I was to slow to merge the same optimization for the open orders query.

@MartinquaXD MartinquaXD requested a review from a team as a code owner February 6, 2026 11:36
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The added filter for ethflow_refunds is correct. However, it creates a redundant join in the solvable_orders query, impacting performance. A fix is suggested in the review comment.

I am having trouble creating individual review comments. Click here to see my feedback.

crates/database/src/orders.rs (732)

high

This filter makes the LEFT JOIN on ethflow_refunds at line 806 redundant. Since live_orders no longer contains refunded orders, tx_hash from ethflow_refunds will always be NULL.

To improve clarity and performance, remove the unnecessary join by changing lines 803-808.

-    LEFT JOIN LATERAL (
-        SELECT ROW(tx_hash, eo.valid_to) AS ethflow_data
-        FROM   ethflow_orders  eo
-        LEFT JOIN ethflow_refunds r ON r.order_uid = eo.uid
-        WHERE  eo.uid = lo.uid
-        ) ed ON TRUE
+    LEFT JOIN LATERAL (
+        SELECT ROW(NULL::bytea, eo.valid_to) AS ethflow_data
+        FROM   ethflow_orders  eo
+        WHERE  eo.uid = lo.uid
+        ) ed ON TRUE

@MartinquaXD MartinquaXD added the hotfix Labels PRs that should be applied into production right away label Feb 6, 2026
@MartinquaXD MartinquaXD enabled auto-merge February 6, 2026 11:48
@MartinquaXD MartinquaXD added this pull request to the merge queue Feb 6, 2026
Merged via the queue into main with commit 950180e Feb 6, 2026
19 checks passed
@MartinquaXD MartinquaXD deleted the tighter-filter-on-all-solvable-orders-query branch February 6, 2026 12:12
@github-actions github-actions bot locked and limited conversation to collaborators Feb 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

hotfix Labels PRs that should be applied into production right away

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants