Query takes too much time (more than 5 minutes to retrieve first 10 documents)
mtech2008 opened this issue · 2 comments
In "products" collection I have around 3000000 documents in a collection and I want to paginate it.
I am using the following query:
{
allProducts(first:10){
edges{
node{
brandname
}
cursor
}
pageInfo{
hasPreviousPage
hasNextPage
startCursor
endCursor
}
}
}
and it either fails or takes too much time to fetch the documents. Please tell me what I am doing wrong.
I've also got this issue.
class User(Document):
meta = {'collection': 'users', 'allow_inheritance': True}
uuid = UUIDField(binary=False, required=True)
state = StringField(choices=STATES, required=True)
class User(MongoengineObjectType):
class Meta:
model = UserModel
interfaces = (Node,)
class Query(graphene.ObjectType):
node = Node.Field()
all_users = MongoengineConnectionField(User)
I've got approx 10k users.
Running:
query test{
allUsers(first:10){
edges{
node{
uuid
state
}
}
}
}
takes 5s
Running
query test{
allUsers{
edges{
node{
uuid
state
}
}
}
}
takes 11s
So returning 10 users takes half the time it takes to return all 10 000.
Restarted in between tests to ensure that results were not cached.
Anyone got any ideas?