perf: Enhance index for token holders list (#9816)
* Enhance index for token holders list * Separate index creation and deletion to different migrationspull/9904/head
parent
c08ea4782c
commit
df660c90c6
@ -0,0 +1,14 @@ |
||||
defmodule Explorer.Repo.Migrations.EnhanceIndexForTokenHoldersList do |
||||
use Ecto.Migration |
||||
@disable_ddl_transaction true |
||||
@disable_migration_lock true |
||||
|
||||
def change do |
||||
create_if_not_exists( |
||||
index(:address_current_token_balances, ["token_contract_address_hash, value DESC, address_hash DESC"], |
||||
where: "address_hash != '\\x0000000000000000000000000000000000000000' AND value > 0", |
||||
concurrently: true |
||||
) |
||||
) |
||||
end |
||||
end |
@ -0,0 +1,14 @@ |
||||
defmodule Explorer.Repo.Migrations.DropOutdatedIndexForTokenHoldersList do |
||||
use Ecto.Migration |
||||
@disable_ddl_transaction true |
||||
@disable_migration_lock true |
||||
|
||||
def change do |
||||
drop_if_exists( |
||||
index(:address_current_token_balances, [:token_contract_address_hash], |
||||
where: "address_hash != '\\x0000000000000000000000000000000000000000' AND value > 0", |
||||
concurrently: true |
||||
) |
||||
) |
||||
end |
||||
end |
Loading…
Reference in new issue