-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove unused Indexes, Unique and Primary Keys #1087
Comments
I am testing something right now which just removes the foreign key constraints. Currently on mainnet epoch |
Removing foreign key constraints (and nothing else) provides significant sync speed improvements when testing on mainnet. For Byron era epochs, the speed improvement is about 25%. For the latest era (Alonzo) the sync speed improvement are from 50% to 70%. Mainnet synced from genesis to epoch |
@rdirt There is still a lot of work to be done on this idea. |
Yip - can definitely imagine the complications it would add to probabilities and careful changes (not expecting this to be ready very soon, and perhaps even introduce bugs =] ), but I can definitely see the benefits in longer term from postgres consumer pov (especially to size of fact tables when doing very large queries across tables) 🙂 |
I really hope we can do enough testing to prevent any bugs escaping into a released version. When complete, I intend to test on |
This is incredibly complex and difficult. My initital test just removed all foreign key constraints and was not able to do any valid rollbacks. Trying to support rollbacks makes everything more difficult. The |
This is about #1082 right? Maybe we can remove references from tables that don't need to rollback. For example |
The tables you mention |
Yes, |
This is WIP. My branch is |
In the same spirit as #1082 we could continue simplifying the schema trying to optimize insertions.
StakeRegistration
,Delegation
,TxIn
,MaTxOut
,MaTxMint
which are not referenced by any other table could probably be deleted.Reward
andEpochStake
need to maintain their Unique keys, since we can have duplicate insertions on rollbacks. However their Primary Id is never used.,Tx
Redeemer
which are referenced by other tables need to maintain their Primary key, but their Unique key can be removed. We already know that their hashes are unique and the specs make sure there will never be any duplicates. We already useinsertUnchecked
on them (or should use), so if there is a violation the whole thing crashes anyway. There is no query on their hashes, but we should audit if they are used in other queries while inserting (removing unique keys would make these slower).StakeAddress
,MultiAsset
,Script
need to maintain both primary and unique keys. The difference with previous tables is that they can be inserted in different places and db-sync may try to insert them multiple times. We also need a way to get their Primary id from their hash.We could also try to audit indexes that are important for syncing and disable all others. Applications that build on top of db-sync could insert their own indexes based on their needs.
The above list probably needs a better audit to check if it's correct for all tables and the mentioned tables can probably be extended.
The text was updated successfully, but these errors were encountered: