Irrelon/ForerunnerDB

Possible bug on indexes usage

no-more opened this issue · 1 comments

Hi,

I'm not sure if this is a bug or the expected behavior but I currently have some trouble using secondary indexes.
If the query's parameter is not exactly the same as the index, the index is never used.
The issue is that I can't always control the query fields order as it's an object.
Sometime I could even have some other fields before the indexed once.

Do you think it's possible to make indexes work in any order? If it's too complicated or to costly to handle this automatically, would it be possible to pass the index name manually to the function ?

Thanks a lot.

Here is an example :

        dbCollection.ensureIndex(
            {
                targetId: 1,
                targetType: 1,
            }
        );
dbCollection.explain({targetType: "52", targetId: "52", "test": "45"});// -> no index used
dbCollection.explain({"test": "45", targetId: "52", targetType: "52"});// -> no index used
dbCollection.explain({targetId: "52", targetType: "52", "test": "45"});// -> index used

Thanks.