diff --git a/database/README.md b/database/README.md index d62b9bda99..734002c82a 100644 --- a/database/README.md +++ b/database/README.md @@ -265,6 +265,13 @@ Column | Type | Nullable | Details Indexes: - PRIMARY KEY: btree(`uid`) +- order_cancellation_timestamp: btree(`cancellation_timestamp`) +- order_creation_timestamp: btree(`creation_timestamp`) +- order_owner: hash(`owner`) +- order_quoting_parameters: btree(`sell_token`, `buy_token`, `sell_amount`) +- order_sell_buy_tokens: btree(`sell_token`, `buy_token`) +- user_order_creation_timestamp: btree(`owner`, `creation_timestamp`) +- version_idx: btree(`settlement_contract`) ### fee_policies diff --git a/database/sql/V095__update_order_timestamp_indexes.sql b/database/sql/V095__update_order_timestamp_indexes.sql new file mode 100644 index 0000000000..93bb687a4c --- /dev/null +++ b/database/sql/V095__update_order_timestamp_indexes.sql @@ -0,0 +1,10 @@ +-- create a separate index for cancellation_timestamp to improve queries +-- filtering based on the cancellation_timestamp +-- no extra index with only the creation_timestamp needs to be created +-- since that already exists. +CREATE INDEX order_cancellation_timestamp ON orders USING BTREE(cancellation_timestamp); + +-- drop index over (creation_timestamp, cancellation timestamp) +-- since it can only be used optimally for queries on the creation_timestamp. +DROP INDEX IF EXISTS order_creation_cancellation; +