hi, I’m new on this forum, so i have same fetch performance problem
-
Query :
{text: /putin/i, "timestamp": {"$gt":1590969600, "$lt": 1598832000}}
-
.explain(“allPlansExecution”) : https://gist.github.com/batara666/e6c1321fba176d32ff74dd986442bd26
-
Driver : mongo-go-driver
-
options.Find():
topt := options.Find()
topt.SetBatchSize(300_000)
topt.SetLimit(300_000)
- Deployed on Compute Engine (app & db running on difference instance)
Code :
ctx, cancel = context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
cur, err := database.Collection("chat").Find(ctx, filter, topt)
if err != nil {
log.Println(err)
fmt.Fprint(w, `{"success": false}`)
return
}
defer cur.Close(ctx)
ctx, cancel = context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
var postResult []post
err = cur.All(ctx, &postResult)
if err != nil {
fmt.Fprint(w, `{"success": false, "message": "All failing"}`)
return
}
returned chat length are ~36k documents and it tooks ~9sec, i need to make it faster, i really frustrated :(, any suggestions would be greatly appreciated