Skip to content

Commit

Permalink
Fix index for ethflow_orders table (#2836)
Browse files Browse the repository at this point in the history
# Description
Previously index was created on a wrong table: "orders" instead of
"ethflow_orders":

https://github.com/cowprotocol/services/blob/main/database/sql/V031__create_ethflow_orders.sql#L11

Should speed up the OPEN_ORDERS query, although not sure how much.
  • Loading branch information
sunce86 authored Jul 29, 2024
1 parent 516719f commit 8e1e306
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions database/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ EthFlow orders get created with the very generic [`ICoWSwapOnchainOrders`](https

Indexes:
- PRIMARY KEY: btree(`uid`)
- ethflow\_user\_valid\_to: btree(`valid_to`)

### ethflow\_refunds

Expand Down
5 changes: 5 additions & 0 deletions database/sql/V067__create_index_on_ethflow_orders.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- To get all valid orders quickly, we create an index
CREATE INDEX ethflow_user_valid_to ON ethflow_orders USING BTREE (valid_to);

-- Remove wrongly added index in V031__create_ethflow_orders.sql
DROP INDEX user_valid_to;

0 comments on commit 8e1e306

Please sign in to comment.