0

Can you filter an indexed event parameters?

Does indexing make filtering more efficient or does indexing make filtering possible?

1 Answer 1

1

Yes, indexing event variables is used for better filtering. indexed values are saved as topics that can be filtered from the start of the RPC call. these values are stored in topics the same way as the name and definition of the event.

3
  • so can I filter unindexed parameters in etherjs?
    – YulePale
    Aug 1, 2021 at 23:32
  • 1
    @YulePale please be aware that ethereum indexing method is not the same as BTREE method in databases. In databases you have a binary tree where the lookup takes O(log(n)) . Here in Ethereum bloom filter is used so it is not clear if it is faster than btree, you need to investiage on this. Apparently it scans blocks with bloom filter sequentially.
    – Nulik
    Aug 2, 2021 at 2:07
  • 1
    @YulePale no, you can't scan unindexed parameters, you have to scan them and build your own DB. For example Uniswap v2 has about 50 million swap events since its release in June 2020 , and I am pretty sure a btree scan would be faster than using Geth.
    – Nulik
    Aug 2, 2021 at 2:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.