Skip to content

Commit

Permalink
Fix performance issue for count queries
Browse files Browse the repository at this point in the history
Fixes #4454
  • Loading branch information
ogenstad committed Sep 25, 2024
1 parent b4ee01b commit 4641863
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
30 changes: 16 additions & 14 deletions backend/infrahub/graphql/types/mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,22 @@ async def get_paginated_list(cls, fields: dict, context: GraphqlContext, **kwarg
edges = fields.get("edges", {})
node_fields = edges.get("node", {})

objs = await NodeManager.query(
db=db,
schema=cls._meta.schema,
filters=filters or None,
fields=node_fields,
at=context.at,
branch=context.branch,
limit=limit,
offset=offset,
account=context.account_session,
include_source=True,
include_owner=True,
partial_match=partial_match,
)
objs = []
if edges or "hfid" in filters:
objs = await NodeManager.query(
db=db,
schema=cls._meta.schema,
filters=filters or None,
fields=node_fields,
at=context.at,
branch=context.branch,
limit=limit,
offset=offset,
account=context.account_session,
include_source=True,
include_owner=True,
partial_match=partial_match,
)

if "count" in fields:
if filters.get("hfid"):
Expand Down
1 change: 1 addition & 0 deletions changelog/4454.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix performance issue for GraphQL queries that only count nodes.

0 comments on commit 4641863

Please sign in to comment.