Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reorganize queries and indexes for internal_transactions table
- Loading branch information
Showing
5 changed files
with
144 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...r/priv/repo/migrations/20191203112646_internal_transactions_add_to_address_hash_index.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
defmodule Explorer.Repo.Migrations.InternalTransactionsAddToAddressHashIndex do | ||
use Ecto.Migration | ||
|
||
def change do | ||
execute( | ||
"CREATE INDEX IF NOT EXISTS internal_transactions_from_address_hash_partial_index on public.internal_transactions(from_address_hash) WHERE (((type = 'call') AND (index > 0)) OR (type != 'call')) AND (NOT (block_number IS NULL));" | ||
) | ||
|
||
execute( | ||
"CREATE INDEX IF NOT EXISTS internal_transactions_to_address_hash_partial_index on public.internal_transactions(to_address_hash) WHERE (((type = 'call') AND (index > 0)) OR (type != 'call')) AND (NOT (block_number IS NULL));" | ||
) | ||
|
||
execute( | ||
"CREATE INDEX IF NOT EXISTS internal_transactions_created_contract_address_hash_partial_index on public.internal_transactions(created_contract_address_hash) WHERE (((type = 'call') AND (index > 0)) OR (type != 'call')) AND (NOT (block_number IS NULL));" | ||
) | ||
|
||
drop_if_exists( | ||
index( | ||
:internal_transactions, | ||
[:to_address_hash, :from_address_hash, :created_contract_address_hash, :type, :index], | ||
name: "internal_transactions_to_address_hash_from_address_hash_created" | ||
) | ||
) | ||
end | ||
end |