Merge pull request #2910 from poanetwork/vb-avoid-complex-index
Reorganize queries and indexes for internal_transactions tablepull/2936/head
commit
1a95ba0cf0
@ -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, block_number DESC, transaction_index DESC, index DESC) WHERE (((type = 'call') AND (index > 0)) OR (type != 'call'));" |
||||
) |
||||
|
||||
execute( |
||||
"CREATE INDEX IF NOT EXISTS internal_transactions_to_address_hash_partial_index on public.internal_transactions(to_address_hash, block_number DESC, transaction_index DESC, index DESC) WHERE (((type = 'call') AND (index > 0)) OR (type != 'call'));" |
||||
) |
||||
|
||||
execute( |
||||
"CREATE INDEX IF NOT EXISTS internal_transactions_created_contract_address_hash_partial_index on public.internal_transactions(created_contract_address_hash, block_number DESC, transaction_index DESC, index DESC) WHERE (((type = 'call') AND (index > 0)) OR (type != 'call'));" |
||||
) |
||||
|
||||
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 |
Loading…
Reference in new issue