Skip to content

Commit

Permalink
chore: combine migration file and add index
Browse files Browse the repository at this point in the history
  • Loading branch information
Sotatek-ThinhVu committed May 7, 2024
1 parent c145441 commit 43d12ee
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-- address_tx_count
DROP MATERIALIZED VIEW IF EXISTS address_tx_count;

CREATE MATERIALIZED VIEW address_tx_count AS
Expand All @@ -8,4 +9,23 @@ FROM address add
GROUP BY add.address;

CREATE INDEX IF NOT EXISTS address_tx_count_address_idx ON address_tx_count (address);
CREATE INDEX IF NOT EXISTS address_tx_count_tx_count_idx ON address_tx_count (tx_count);
CREATE INDEX IF NOT EXISTS address_tx_count_tx_count_idx ON address_tx_count (tx_count);

-- token_tx_count
DROP MATERIALIZED VIEW IF EXISTS token_tx_count;

CREATE MATERIALIZED VIEW token_tx_count as
SELECT ma.id as ident, count(distinct (ata.tx_hash)) as tx_count
FROM address_tx_amount ata
JOIN multi_asset ma ON ata.unit = ma.unit
GROUP BY ma.id;

CREATE INDEX IF NOT EXISTS token_tx_count_ident_idx ON token_tx_count(ident);
CREATE INDEX IF NOT EXISTS token_tx_count_tx_count_idx ON token_tx_count(tx_count);

-- add index for address entitys

CREATE INDEX IF NOT EXISTS address_address_hash_idx ON address using hash (address);
CREATE INDEX IF NOT EXISTS address_payment_credential_hash_idx ON address using hash (payment_credential);
CREATE INDEX IF NOT EXISTS address_stake_address_hash_idx ON address using hash (stake_address);
CREATE INDEX IF NOT EXISTS address_stake_credential_hash_idx ON address using hash (stake_credential);

This file was deleted.

0 comments on commit 43d12ee

Please sign in to comment.