While implementing our app we come to situation when multiple indexes on same collection significantly slowdown search. In our example we have collection that store information about financial transactions. To speedup app we need to maintain separate helper collection that holds links between accounts and transaction splits. This helper collection holds account and transaction ids with some derivative information like date and sum. It has indexes for both account and transaction ids. During update we use search query that include both ids and by default TingoDB tries to use both indexes. It found ranges and then intersect them. With some experimentation we found that using only single transaction id index can speedup thing a lot. This happens because transactions usually consists from few splits (usually two). So, using only one transaction index to fetch those few records with additional check of account id fields appears to be much faster that using both indexes.

Probably this is good example why MongoDB support search hint option which you can use to point exact index you want to use. So it was easy to add this support and we did it.

Hints option is available in TingoDB since version 0.1.3

Leave a Reply