From ddda3026b60bf265369a6b35f893d776ef38a80c Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Wed, 9 Oct 2019 15:28:39 +0300 Subject: [PATCH] optimize token token transfers query the longes part of the query is ordering. Removing order clause from the query makes a query much faster. It's because by default indexes are ordered in ASC order --- ...1009121635_add_token_transfer_sorting_indexes.exs | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 apps/explorer/priv/repo/migrations/20191009121635_add_token_transfer_sorting_indexes.exs diff --git a/apps/explorer/priv/repo/migrations/20191009121635_add_token_transfer_sorting_indexes.exs b/apps/explorer/priv/repo/migrations/20191009121635_add_token_transfer_sorting_indexes.exs new file mode 100644 index 0000000000..65b4c004d2 --- /dev/null +++ b/apps/explorer/priv/repo/migrations/20191009121635_add_token_transfer_sorting_indexes.exs @@ -0,0 +1,12 @@ +defmodule Explorer.Repo.Migrations.AddTokenTransferSortingIndexes do + use Ecto.Migration + + def change do + create( + index( + :token_transfers, + ["block_number DESC", "log_index DESC"] + ) + ) + end +end