Skip to content

Commit

Permalink
151 increase trade query performance (#152)
Browse files Browse the repository at this point in the history
* add index for latest market datum buy_price, sell_price, stock, demand.
     pricing may not need indexing for trade algo but will improve commodity look up and commodity market view

 Add index for station arrival distance
  • Loading branch information
Daniel-J-Mason authored Mar 15, 2024
1 parent 8115f03 commit 83a0318
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">

<changeSet id="add_latest_market_datum_demand_supply_price_indexes" author="daniel-j-mason">
<createIndex indexName="idx_latest_market_datum_buy_price" tableName="latest_market_datum">
<column name="buy_price" />
</createIndex>

<createIndex indexName="idx_latest_market_datum_sell_price" tableName="latest_market_datum">
<column name="sell_price" />
</createIndex>

<createIndex indexName="idx_latest_market_datum_demand" tableName="latest_market_datum">
<column name="demand" />
</createIndex>

<createIndex indexName="idx_latest_market_datum_stock" tableName="latest_market_datum">
<column name="stock" />
</createIndex>
</changeSet>

</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">

<changeSet id="add_station_arrival_distance_index" author="daniel-j-mason">
<createIndex indexName="idx_station_arrival_distance" tableName="station">
<column name="arrival_distance" />
</createIndex>
</changeSet>

</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
<include file="/db/trademodule/changelog/create_latest_market_datum_table.xml"/>
<include file="/db/trademodule/changelog/fill_latest_market_datum.xml"/>
<include file="/db/trademodule/changelog/add_unique_index_commodity_name.xml"/>
<include file="/db/trademodule/changelog/add_latest_market_datum_demand_supply_price_indexes.xml"/>
<include file="/db/trademodule/changelog/add_station_arrival_distance_index.xml"/>

<!-- views always last as they might depend on new columns -->
<include file="/db/trademodule/changelog/create_validated_commodity_view.xml"/>
Expand Down

0 comments on commit 83a0318

Please sign in to comment.