graphql-python / graphql-python/graphene

schema.execute is fast, but GraphQLView's get_response is very slow

Ouverte
#1,266 1 commentaire 10 réactions 0 personnes assignées Voir sur GitHub
🐛 bug
Langage dominant
Python
Étoiles
8.2k
Forks
818
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

* **What is the current behavior?**
I have a query that returns a semi-large amount of data (1.3MB, maybe 100,000 objects). When I run the query using `response = schema.execute(query)`, it takes less than a second to receive a response with all the data in response.data; however, if I query the data through the local Django server (via GraphQL Playground or my frontend application), it takes 10+ seconds for the server to send the response.

I initially assumed this was being caused by the serialization of the data from the database. I knew the queries were taking only 1/100th of a second based on the django_silk query/profiler results. However, the fast response from schema.execute rules out the serialization process being the issue.

Running cProfiler on Django doesn't appear to trace through the GraphQLView (any explanation of why this might be would be greatly appreciated). However, I was able to create a dynamic profiler with django_silk to confirm that it's something within `GraphQLView.get_response()` that's causing the slowdown

* **What is the expected behavior?**
I'd expect the response to not take 1000x as long to send as the time taken to query and serialize the data.

* **Please tell us about your environment:**

- Version:
```
graphene==2.1.8
graphene-django==2.10.1
graphene-django-optimizer==0.6.2
```

* **Other information** (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow)
[StackOverflow question initially opened regarding this matter](https://stackoverflow.com/questions/63964764/graphene-python-performance-issues-for-large-data-sets)

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Piste de recherche

Commencez par GraphQLView.get_response() et comparez son chemin de requête avec le chemin direct schema.execute(query) décrit dans l’issue. Utilisez les résultats de profilage django-silk et les observations de cProfiler rapportés pour isoler le ralentissement, puis vérifiez qu’une réponse volumineuse est transmise sans le délai de plus de 10 secondes signalé.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
django, graphql, python
Domaine
api, backend, performance
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
25/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.