Reputation: 10413
I have a large table that grows rapidly. I want to filter by a field then get the distinct values by another field. However in RethinkDB, this causes all records to be read from disk as I see from dashboard, which takes too much time. My query is as follows:
r.db("mydb").table("mytable").filter({"AssetID": "a"}).pluck("StartedOn").distinct()
The original query was follows but RethinkDB gives an error that it is not a table.
r.db("mydb").table("mytable").filter({"AssetID": "a"}).distinct({index:"StartedOn"})
e: Can only perform an indexed distinct on a TABLE in:
Both fields StartedOn and AssetID are indexed. filter
does not use index, so I tried to use getAll
but still same error:
r.db("mydb").table("mytable").getAll("a", {index: 'AssetID'}).distinct({index:"StartedOn"})
e: Can only perform an indexed distinct on a TABLE in:
Upvotes: 0
Views: 438
Reputation: 5289
You can't getAll
by one index and then use an indexed distinct
on another index. I would recommend an unindexed distinct
after a getAll
in this case.
Upvotes: 2