Irrelon / ForerunnerDB

A JavaScript database with mongo-like query language, data-binding support, runs in browsers and hybrid mobile apps as a client-side DB or on the server via Node.js!

Home Page:http://www.irrelon.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Range searches do not use available index

edwardcoolson opened this issue · 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.

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

Thank you Rob. Will be waiting for improvements.

hi, @Irrelon! any progress with that?

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 ;-(

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 👍