From 1effae8950017bd946baf1ee592adc5d9d6ee2a4 Mon Sep 17 00:00:00 2001 From: g0rbe Date: Wed, 19 Jul 2023 04:51:22 +0200 Subject: [PATCH] fix slow response: remove batchSize options --- db/lookup.go | 5 ++--- db/records.go | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/db/lookup.go b/db/lookup.go index aef7362..d8d3936 100644 --- a/db/lookup.go +++ b/db/lookup.go @@ -10,7 +10,6 @@ import ( "github.com/elmasy-com/slices" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/mongo/options" ) // Lookup query the DB and returns a list subdomains only. @@ -52,7 +51,7 @@ func Lookup(d string, days int) ([]string, error) { } // Use Find() to find every shard of the domain - cursor, err := Domains.Find(context.TODO(), doc, options.Find().SetBatchSize(100)) + cursor, err := Domains.Find(context.TODO(), doc) if err != nil { return nil, fmt.Errorf("failed to find: %s", err) } @@ -118,7 +117,7 @@ func LookupFull(d string, days int) ([]string, error) { } // Use Find() to find every shard of the domain - cursor, err := Domains.Find(context.TODO(), doc, options.Find().SetBatchSize(100)) + cursor, err := Domains.Find(context.TODO(), doc) if err != nil { return nil, fmt.Errorf("failed to find: %s", err) } diff --git a/db/records.go b/db/records.go index fbcb932..663446f 100644 --- a/db/records.go +++ b/db/records.go @@ -405,7 +405,7 @@ func TopListUpdater(wg *sync.WaitGroup) { start := time.Now() - cursor, err := TopList.Find(context.TODO(), bson.M{}, options.Find().SetBatchSize(10).SetSort(bson.M{"count": -1})) + cursor, err := TopList.Find(context.TODO(), bson.M{}, options.Find().SetSort(bson.M{"count": -1})) if err != nil { fmt.Fprintf(os.Stderr, "TopListUpdater() failed to find toplist: %s\n", err) continue