2016-08-03 41 views
0

我有一個快速增長的大表。我想按字段進行過濾,然後通過另一個字段獲取不同的值。然而,在RethinkDB中,這會導致從儀表板讀取所有記錄,這是需要太多時間的。我的查詢如下:RethinkDB篩選器然後按索引區分

r.db("mydb").table("mytable").filter({"AssetID": "a"}).pluck("StartedOn").distinct() 

最初的查詢是,但RethinkDB給出了一個錯誤,它不是一個表。

r.db("mydb").table("mytable").filter({"AssetID": "a"}).distinct({index:"StartedOn"}) 
e: Can only perform an indexed distinct on a TABLE in: 

FieldsOn和AssetID都被編入索引。 filter不使用索引,所以我試圖用getAll但還是同樣的錯誤:

r.db("mydb").table("mytable").getAll("a", {index: 'AssetID'}).distinct({index:"StartedOn"}) 
e: Can only perform an indexed distinct on a TABLE in: 

回答

2

您可以通過getAll沒有一個指數,然後在另一個索引使用索引distinct。在這種情況下,我會推薦getAll之後的未索引distinct