Closed Bug 1378473 Opened 8 years ago Closed 8 years ago

GraphQL should use select_related and prefetch_related to optimize queries

Categories

(Tree Management :: Treeherder, enhancement)

enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: camd, Assigned: camd, Mentored)

References

Details

(Whiteboard: [lang=py])

Attachments

(2 files)

The GraphQL queries are doing tons of tiny sub-queries. They are pretty slow, and causing noise in New Relic. It should be possible to optimize them. This MAY involve a patch to Graphene-django, because it appears this is not supported in that package for fields that are filtered.
Blocks: 1337488
Blocks: 1378487
Mentor: cdawson
Whiteboard: [lang=py]
Blocks: 1290039
Attachment #8888575 - Flags: review?(emorley)
Comment on attachment 8888575 [details] [review] [treeherder] mozilla:optimize-graphql-queries > mozilla:master This looks great! Few tweaks and we should be good to go :-)
Attachment #8888575 - Flags: review?(emorley) → feedback+
Attachment #8888575 - Flags: review+
Commits pushed to master at https://github.com/mozilla/treeherder https://github.com/mozilla/treeherder/commit/c477ea68f1264ae6464491c76ad14cc7b205516b Bug 1378473 - Add related_name to a few models to help with GraphQL references Also add a ``name`` to the GraphQL url so ``reverse`` can be used on it. https://github.com/mozilla/treeherder/commit/9069346f5e707c0bcf0f825de03d203d49507cf4 Bug 1378473 - Add support for select_related and prefetch_related to GraphQL The GraphQL queries for the TestGroup UI were creating too many sub-queries. There is a bug in graphene_django that eliminates any usage of select_related or prefetch_related. This works around that limitation and allows the user to create a mapping of fields to the optimization that can be used for each. It will only apply the optimization if the field is present in the query.
Commit pushed to master at https://github.com/mozilla-rpweb/treeherder-manifest https://github.com/mozilla-rpweb/treeherder-manifest/commit/17dcccda520e7e55998eee435405cf7151a87464 Bug 1378473 - Fix queries to match changes in Treeherder (#20) The addition of support for select_related to the GraphQL Queries in Treeherder required some slight changes to the field names in the GraphQL queries.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Assignee: nobody → cdawson
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: