IntersectMBO / cardano-db-sync

A component that follows the Cardano chain and stores blocks and transactions in PostgreSQL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Speed up the prune migration

kderme opened this issue · comments

Let's say we run the prune migration on a db which is close to being fully synced. The prune migration initially runs the consumed migrations, which marks all consumed tx_out and then it deletes all the old enough tx_out. It could become faster by directly deleting the old enough consumed tx_out, instead of doint it in 2 steps.
So instead of running in runExtraMigrations

migrateTxOut
deleteConsumedTxOut

These can be run as

deleteConsumedTxOut' -- different from the above
migrateTxOut

@kderme just a couple of question for clarification:

runExtraMigrations happens here inside of runSyncNode which happens once. deleteConsumedTxOut happens at an interval of every epoch here.

  1. Is the idea to deleteConsumedTxOut just before runExtraMigrations?

  2. If so you mention the function deleteConsumedTxOut should be different how so?

Other usages of deleteConsumedTxOut shouldn't be affected by this. Only 1 of the 2 usages of deleteConsumedTxOut in runExtraMigrations should change its behaviour. Basically it should work without the need of running migrateTxOut and creating the extra column before it.