Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve performance of fee policies and fees (#2970)
# Description Apparently, Postgresql optimal way of matching data against large input is using INNER JOIN: https://stackoverflow.com/questions/24647503/performance-issue-in-update-query So, the benchmark for the problematic [order](https://aws-es.cow.fi/_dashboards/app/data-explorer/discover#?_a=(discover:(columns:!(log,log_level),isDirty:!f,sort:!()),metadata:(indexPattern:'86e4a5a0-4e4b-11ef-85c5-3946a99ed1a7',view:discover))&_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:'2024-09-10T11:46:17.292Z',to:'2024-09-10T13:48:25.292Z'))&_q=(filters:!(),query:(language:kuery,query:'log:%20%229649c7739ced0ea0fb0ecd8c41c81100%22'))) on arbitrum is: 1. Current implementation: ~1.5s - 3s 2. WHERE .. IN: same as (1) 3. INNER JOIN: 100ms-300ms 4. grouping by order_uid: same as (3) That said, I chose INNER JOIN as the cleanest solution in terms of code. Total time spent to get trades should be at most 500ms after this change (150ms on average). ## How to test Tested locally against arbitrum read replica. Also tested with a regular order that has only one trade and this code does not degrade performance for that case.
- Loading branch information