Reputation: 3483
introduction
I have been working with the ReThink Db using data explorer tab. I am new to Rethink Db.
I have created this query to filter record on date base. I needed to optimize the query so that it can take less time for large records.
r.db('test').table('usrz').filter(function(test) {
return test("createdDate").date().during(
r.time(2016,12,20, 'Z'),
r.time(2016,12,30, 'Z'))
}).orderBy(r.desc('createdDate'))
Any help or reference will be apreciated. Thanks for your time.
Upvotes: 0
Views: 174
Reputation: 7184
RethinkDB queries can be optimized by using indexes. (see https://www.rethinkdb.com/docs/secondary-indexes/javascript)
To create an index:
r.table('usrz').indexCreate('createdDate')
Your query can be converted to use that index by transforming the filter
/during
combination into a between
and by adding an index
argument to orderBy
Upvotes: 1