Skip to content

Conversation

@micahriggan
Copy link
Owner

@micahriggan micahriggan commented Sep 18, 2020

Hashes in index is bad

If you index a hash, you have a bad time, because you have to constantly restructure the B-Tree for the index.

This is because the hashes are random, and you may need to insert a node in-between two other hashes.

Object ID indexes would be good

If you use an increasing value, like ObjectId, then the B-Tree is basically append only

So I wanted to try changing the indexes to using ObjectIds for mintTxid and spentTxid

These properties are called _mintTx and _spentTx

Outcome

I did a quick test and this does appear to be about 20% faster out of the gate, and I have a feeling would retain it's syncing speed better than the hash index version.

Unfortunately, you lose some nice safety concerns, and I'm not sure of the structural integrity of mempool txs, since you'd need to make sure you didn't create coins with a new _mintTx that were previously minted.

Basically for each TX being created, you'd have to first make sure it wasn't already in the DB, if it is, use that _id

I think doing all those finds might actually still be faster than trying to using hashes for the mintTxid and spentTxid indexes.

@micahriggan micahriggan changed the title Feature/no hash index Experiement: Don't use Hashes in Coin Indexes Sep 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants