0

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.

Suhail Mumtaz Awan
  • 3,295
  • 8
  • 43
  • 77

1 Answers1

1

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

Etienne Laurin
  • 6,731
  • 2
  • 27
  • 31