graphql-python / graphql-python/graphene

Performance issues with large data sets

オープン
#268 コメント 82 件 リアクション 29 件 担当者 0 名 GitHub で見る
✨ enhancement work in progress
主要言語
Python
スター
8.2k
フォーク
818
PR マージ指標
30日以内にマージされた PR はありません

説明

For our use case, we send a few thousand objects to the client. We're currently using a normal JSON API, but are considering using GraphQL instead. However, when returning a few thousand objects, the overhead of resolving values makes it impractical to use. For instance, the example below returns 10000 objects with an ID field, and that takes around ten seconds to run.

Is there a recommended way to improve the performance? The approach I've used successfully so far is to use the existing parser to parse the query, and then generate the response by creating dictionaries directly, which avoids the overhead of resolving/completing on every single value.

``` python
import graphene

class UserQuery(graphene.ObjectType):
id = graphene.Int()

class Query(graphene.ObjectType):
users = graphene.Field(UserQuery.List())

def resolve_users(self, args, info):
return users

class User(object):
def __init__(self, id):
self.id = id

users = [User(index) for index in range(0, 10000)]

schema = graphene.Schema(query=Query)

print(schema.execute('{ users { id } }').data)
```

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。