perf: Improve performance of token page transfers tab (#9809)

* Improve performance of token page transfers tab

* mix format

* Separate index creation and deletion to defferent migrations

* Rename migration
pull/9904/head
Victor Baranov 7 months ago committed by GitHub
parent 01fe4e5537
commit 0c5278c8be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      apps/explorer/lib/explorer/graphql.ex
  2. 11
      apps/explorer/priv/repo/migrations/20240403151125_enhance_index_for_token_transfers_list.exs
  3. 9
      apps/explorer/priv/repo/migrations/20240403151126_drop_outdated_index_for_token_transfers_list.exs

@ -93,7 +93,7 @@ defmodule Explorer.GraphQL do
tt in TokenTransfer,
inner_join: t in assoc(tt, :transaction),
where: tt.token_contract_address_hash == ^token_contract_address_hash,
order_by: [desc: tt.block_number],
order_by: [desc: tt.block_number, desc: tt.log_index],
select: tt
)
end

@ -0,0 +1,11 @@
defmodule Explorer.Repo.Migrations.EnhanceIndexForTokenTransfersList do
use Ecto.Migration
@disable_ddl_transaction true
@disable_migration_lock true
def change do
create_if_not_exists(
index(:token_transfers, ["token_contract_address_hash, block_number DESC, log_index DESC"], concurrently: true)
)
end
end

@ -0,0 +1,9 @@
defmodule Explorer.Repo.Migrations.DropOutdatedIndexForTokenTransfersList do
use Ecto.Migration
@disable_ddl_transaction true
@disable_migration_lock true
def change do
drop_if_exists(index(:token_transfers, [:token_contract_address_hash, :block_number], concurrently: true))
end
end
Loading…
Cancel
Save