From aee507476e5c81ffaa610214652b5ac1028cd3fb Mon Sep 17 00:00:00 2001 From: Daniel-J-Mason Date: Fri, 24 May 2024 21:56:25 -0700 Subject: [PATCH] add station to station limiter limiter, significantly improves performance --- .../MybatisLocateSingleHopTradeRouteRepository.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/trade-module/src/main/java/io/edpn/backend/trade/adapter/persistence/repository/MybatisLocateSingleHopTradeRouteRepository.java b/trade-module/src/main/java/io/edpn/backend/trade/adapter/persistence/repository/MybatisLocateSingleHopTradeRouteRepository.java index f10dbbc2..ba44233d 100644 --- a/trade-module/src/main/java/io/edpn/backend/trade/adapter/persistence/repository/MybatisLocateSingleHopTradeRouteRepository.java +++ b/trade-module/src/main/java/io/edpn/backend/trade/adapter/persistence/repository/MybatisLocateSingleHopTradeRouteRepository.java @@ -95,6 +95,7 @@ sell_market AS (SELECT commodity_id, st_3ddistance(buy_market.coordinates_geom, sell_market.coordinates_geom) AS route_distance FROM buy_market INNER JOIN sell_market ON buy_market.commodity_id = sell_market.commodity_id + AND st_3ddwithin(sell_market.coordinates_geom, buy_market.coordinates_geom, #{maxRouteDistance}) AND buy_market.buy_station_id != sell_market.sell_station_id AND 100 >= buy_market.rn WHERE (sell_market.sell_price - buy_market.buy_price) > 0 @@ -200,6 +201,7 @@ sell_market AS (SELECT commodity_id, st_3ddistance(buy_market.coordinates_geom, sell_market.coordinates_geom) AS route_distance FROM buy_market INNER JOIN sell_market ON buy_market.commodity_id = sell_market.commodity_id + AND st_3ddwithin(sell_market.coordinates_geom, buy_market.coordinates_geom, #{maxRouteDistance}) AND buy_market.buy_station_id != sell_market.sell_station_id AND 100 >= buy_market.rn WHERE (sell_market.sell_price - buy_market.buy_price) > 0 @@ -291,6 +293,7 @@ sell_market AS (SELECT commodity_id, st_3ddistance(buy_market.coordinates_geom, sell_market.coordinates_geom) AS route_distance FROM buy_market INNER JOIN sell_market ON buy_market.commodity_id = sell_market.commodity_id + AND st_3ddwithin(sell_market.coordinates_geom, buy_market.coordinates_geom, #{maxRouteDistance} AND buy_market.buy_station_id != sell_market.sell_station_id AND 100 >= sell_market.rn WHERE (sell_market.sell_price - buy_market.buy_price) > 0 @@ -383,6 +386,7 @@ sell_market AS (SELECT commodity_id, st_3ddistance(buy_market.coordinates_geom, sell_market.coordinates_geom) AS route_distance FROM buy_market INNER JOIN sell_market ON buy_market.commodity_id = sell_market.commodity_id + AND st_3ddwithin(sell_market.coordinates_geom, buy_market.coordinates_geom, #{maxRouteDistance}) AND buy_market.buy_station_id != sell_market.sell_station_id AND 100 >= sell_market.rn WHERE (sell_market.sell_price - buy_market.buy_price) > 0