From 8ad5a3103ec9337e3a1095ae4748611069b68483 Mon Sep 17 00:00:00 2001 From: Amanda Sposito Date: Tue, 27 Nov 2018 11:12:33 -0200 Subject: [PATCH] Add index to addresses table Creates a partial index using the fetched_coin_balance and hash columns --- .../20181126203826_add_index_to_addresses.exs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 apps/explorer/priv/repo/migrations/20181126203826_add_index_to_addresses.exs diff --git a/apps/explorer/priv/repo/migrations/20181126203826_add_index_to_addresses.exs b/apps/explorer/priv/repo/migrations/20181126203826_add_index_to_addresses.exs new file mode 100644 index 0000000000..3c1b16dfec --- /dev/null +++ b/apps/explorer/priv/repo/migrations/20181126203826_add_index_to_addresses.exs @@ -0,0 +1,13 @@ +defmodule Explorer.Repo.Migrations.AddIndexToAddresses do + use Ecto.Migration + + def up do + execute( + "CREATE INDEX addresses_fetched_coin_balance_hash_index ON addresses (fetched_coin_balance DESC, hash ASC) WHERE fetched_coin_balance > 0" + ) + end + + def down do + execute("DROP INDEX addresses_fetched_coin_balance_hash_index") + end +end