Skip to content

Commit

Permalink
Add index on auction id (#2386)
Browse files Browse the repository at this point in the history
# Description
@fhenneke
[reported](cowprotocol/solver-rewards#337) that
the batch rewards query takes forever once we removed the
`auction_transaction` table.
cowprotocol/solver-rewards#334

This should be fixed by adding the index on `auction_id` on
`settlements` table.

## How to test
Execute batch rewards on staging db to verify the speed.
  • Loading branch information
sunce86 authored Feb 9, 2024
1 parent a0e6c05 commit b78d9fd
Show file tree
Hide file tree
Showing 2 changed files with 3 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 @@ -318,6 +318,7 @@ During the solver competition solvers promise a solution of a certain quality. I

Indexes:
- PRIMARY KEY: btree(`block_number`, `log_index`)
- settlements\_auction\_id: btree(`auction_id`)

### settlement\_scores

Expand Down
2 changes: 2 additions & 0 deletions database/sql/V062__settlements_auction_id_index.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Optimization for when we JOIN settlements on auction_id.
CREATE INDEX settlements_auction_id ON settlements USING BTREE (auction_id);

0 comments on commit b78d9fd

Please sign in to comment.