Skip to content

Commit

Permalink
convert the compound indexes used for query optimization, improves al…
Browse files Browse the repository at this point in the history
…l queries across the board by about 1s (#182)
  • Loading branch information
Daniel-J-Mason authored May 24, 2024
1 parent b153243 commit 54669cd
Showing 1 changed file with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,17 @@
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">

<changeSet id="add_latest_market_datum_cover_indexes" author="daniel-j-mason">
<createIndex tableName="latest_market_datum" indexName="latest_market_datum_compound_buy_market_index">
<column name="station_id"/>
<column name="commodity_id"/>
<column name="timestamp"/>
<column name="buy_price"/>
<column name="stock"/>
<column name="mean_price"/>
</createIndex>
<createIndex tableName="latest_market_datum" indexName="latest_market_datum_compound_sell_market_index">
<column name="station_id"/>
<column name="commodity_id"/>
<column name="timestamp"/>
<column name="sell_price"/>
<column name="demand"/>
<column name="mean_price"/>
</createIndex>
<sql>
CREATE INDEX
latest_market_datum_compound_buy_market_index
ON latest_market_datum (station_id, timestamp) include (commodity_id, buy_price, stock, mean_price);
</sql>

<sql>
CREATE INDEX
latest_market_datum_compound_sell_market_index
ON latest_market_datum (station_id, timestamp) include (commodity_id, sell_price, demand, mean_price);
</sql>
</changeSet>

</databaseChangeLog>

0 comments on commit 54669cd

Please sign in to comment.