Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cardano-db/src/Cardano/Db/Schema/Core/StakeDelegation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ data EpochStake = EpochStake
type instance Key EpochStake = EpochStakeId

instance DbInfo EpochStake where
uniqueFields _ = ["addr_id", "pool_id", "epoch_no"]
uniqueFields _ = ["epoch_no", "addr_id", "pool_id"]
unnestParamTypes _ =
[ ("addr_id", "bigint[]")
, ("pool_id", "bigint[]")
Expand Down
2 changes: 1 addition & 1 deletion schema/migration-2-0029-20240117.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ BEGIN
EXECUTE 'ALTER TABLE "instant_reward" DROP COLUMN "earned_epoch"' ;
EXECUTE 'ALTER TABLE "instant_reward" ADD COLUMN "earned_epoch" bigint NOT NULL GENERATED ALWAYS AS ((CASE WHEN spendable_epoch >= 1 then spendable_epoch-1 else 0 end)) STORED' ;
EXECUTE 'ALTER TABLE "instant_reward" DROP COLUMN "pool_id"' ;
EXECUTE 'ALTER TABLE "instant_reward" ADD CONSTRAINT "unique_instant_reward" UNIQUE("addr_id","earned_epoch","type")' ;
EXECUTE 'ALTER TABLE "instant_reward" ADD CONSTRAINT "unique_instant_reward" UNIQUE("earned_epoch","addr_id","type")' ;

EXECUTE 'DELETE FROM "reward" WHERE "pool_id" IS NULL' ;
EXECUTE 'ALTER TABLE "reward" ALTER COLUMN "pool_id" SET NOT NULL' ;
Expand Down
10 changes: 10 additions & 0 deletions schema/migration-4-0010-20260704.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

CREATE INDEX IF NOT EXISTS idx_redeemer_tx_id ON redeemer(tx_id);
CREATE INDEX IF NOT EXISTS idx_collateral_tx_out_tx_id ON collateral_tx_out(tx_id);
CREATE INDEX IF NOT EXISTS idx_reference_tx_in_tx_in_id ON reference_tx_in(tx_in_id);
CREATE INDEX IF NOT EXISTS idx_tx_metadata_tx_id_key ON tx_metadata(tx_id, key);
DROP INDEX IF EXISTS idx_tx_metadata_tx_id;

-- faster autoanalyze on heavy tables:
ALTER TABLE public.block SET (autovacuum_analyze_scale_factor = 0.02, autovacuum_analyze_threshold = 5000);
ALTER TABLE public.tx SET (autovacuum_analyze_scale_factor = 0.02, autovacuum_analyze_threshold = 5000);
Loading