From cd2e3eebb90a36d408f0da0543a901a39324a2a8 Mon Sep 17 00:00:00 2001 From: JinGyeong Jeong Date: Wed, 13 Nov 2019 18:18:45 +0900 Subject: [PATCH] Optimize the performance of the fee-stats API This patch changes the Transactions table's index for the optimization. --- ...hange-transaction-index-is-pending-type.js | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/migrations/20191113091514-change-transaction-index-is-pending-type.js diff --git a/src/migrations/20191113091514-change-transaction-index-is-pending-type.js b/src/migrations/20191113091514-change-transaction-index-is-pending-type.js new file mode 100644 index 0000000..ec9b2b1 --- /dev/null +++ b/src/migrations/20191113091514-change-transaction-index-is-pending-type.js @@ -0,0 +1,23 @@ +"use strict"; + +module.exports = { + up: async (queryInterface, Sequelize) => { + await queryInterface.removeIndex("Transactions", ["isPending"]); + await queryInterface.addIndex("Transactions", [ + "isPending", + "type", + "blockNumber", + "transactionIndex" + ]); + }, + + down: async (queryInterface, Sequelize) => { + await queryInterface.removeIndex("Transactions", [ + "isPending", + "type", + "blockNumber", + "transactionIndex" + ]); + await queryInterface.addIndex("Transactions", ["isPending"]); + } +};