ForerunnerDB icon indicating copy to clipboard operation
ForerunnerDB copied to clipboard

Range searches do not use available index

Open edwardcoolson opened this issue 11 years ago • 5 comments

Range searches perform slow even if the index is created for those searches. I tried range query using the example code from Indices & Performance doc chapter:

var db = new ForerunnerDB(),
    names = ['Jim', 'Bob', 'Bill', 'Max', 'Jane', 'Kim', 'Sally', 'Sam'],
    collection = db.collection('test'),
    tempName,
    tempAge,
    i;

for (i = 0; i < 100000; i++) {
    tempName = names[Math.ceil(Math.random() * names.length) - 1];
    tempAge = Math.ceil(Math.random() * 100);

    collection.insert({
        name: tempName,
        age: tempAge
    });
}

collection.ensureIndex({
  age: 1
});

var explained = collection.explain({
  age: {
    '$gte': 30,
    '$lte': 40
  }
});

'Explained' object has tableScan: 100000 as if no index is used.

edwardcoolson avatar Nov 27 '14 14:11 edwardcoolson

I'll take a look. Range searches may not be index aware right now but it should be a simple fix. :)

Irrelon avatar Nov 27 '14 23:11 Irrelon

Thank you Rob. Will be waiting for improvements.

edwardcoolson avatar Nov 28 '14 10:11 edwardcoolson

hi, @Irrelon! any progress with that?

olegabr avatar Dec 18 '14 09:12 olegabr

It is a critical feature for me. I've tried to dig into the code in a hope to implement it by myself, but it is not easy. The key is the Path concept used everywhere in the code. For now I choosed to abandon the forerunnerdb in a favor of mongodb that supports such a feature. Yes it doesn't work in a browser and it constrains me a lot, but better have something on the server side only, instead of having nothing everywere ;-(

olegabr avatar Dec 23 '14 07:12 olegabr

Hi @olegabr,

This fix is on the roadmap for 1.4.0. The paths system isn't likely to require changes, only the way the indexes are detected against the query and the code that can understand how to query that index based on a range search.

Also please note that ForerunnerDB is still young and enhancements are being made regularly! :) It is not meant to replace MongoDB but rather compliment it so it's good you are using Mongo :+1:

Irrelon avatar Dec 23 '14 13:12 Irrelon