Unable to find the right index

Hi there, I’m unable to find a good index for my query. Does anybody have a good idea for this query?

collection.find({
_id: { $gt: index },
blockchain: ‘test’,
blockHeight: { $gte: 0, $lte: 19500000 },
$or: [
{ ‘tx.txid’: { $in: [strings…] } },
{ ‘tx.vout.scriptPubKey.addresses’: { $in: [strings…] } },
],
})
.sort({ _id: 1 })
.limit(100)

Currently mongo uses only these two indexes, but this takes currently 4s to finish.
IXSCAN { blockchain: 1, tx.txid: 1 }, IXSCAN { blockchain: 1, tx.vout.scriptPubKey.addresses: 1 }

These are my current indexes:
blockchain_1_tx.txid_1
blockchain_1_tx.vout.scriptPubKey.addresses_1
blockchain_1_blockHeight_-1
blockHeight_1__id_1
_id_1_blockchain_1_bockHeight_1_tx.txid_1
_id_1_blockchain_1_bockHeight_1_tx.vout.scriptPubKey.addresses_1
_id_1_blockchain_1_bockHeight_1_tx.vout.scriptPubKey.addresses_1_tx.txid_1

Equality, sort, range filters → blockchain, tx.txid, _id, blockHeight seems to work fine.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.