ergoplatform / explorer-backend

Ergo Blockchain Explorer
22 stars 31 forks source link

DB Index is created over ergoTreeTemplate which is being created for all ergoTrees instead of just P2PK #252

Open pragmaxim opened 1 year ago

pragmaxim commented 1 year ago

Hi,

This might improve performance a lot in both query time and indexing time.

Problem :

pragmaxim commented 1 year ago

I overlooked that the index is already skipping the FeeContract https://github.com/ergoplatform/explorer-backend/blob/master/modules/explorer-core/src/main/resources/db/V9__Schema.sql#L153 WHERE NOT ergo_tree_template_hash = 'd19683030193a38cc7b2a57300000193c2b2a57301007473027303830108cdeeac93b1a57304'; This should be done even for any P2PK as they all have the same template

Ideally storing NULL in these cases and then do :

CREATE INDEX "node_outputs__ergo_tree_template_hash" ON node_outputs (ergo_tree_template_hash)
    WHERE ergo_tree_template_hash IS NOT NULL;