Skip to content

Commit 37921b6

Browse files
authored
Merge pull request #4459 from opsmill/pog-fix-count-only-queries-IFC-733
Fix performance issue for count only queries
2 parents 3daa117 + 4641863 commit 37921b6

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

backend/infrahub/graphql/types/mixin.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,22 @@ async def get_paginated_list(cls, fields: dict, context: GraphqlContext, **kwarg
5151
edges = fields.get("edges", {})
5252
node_fields = edges.get("node", {})
5353

54-
objs = await NodeManager.query(
55-
db=db,
56-
schema=cls._meta.schema,
57-
filters=filters or None,
58-
fields=node_fields,
59-
at=context.at,
60-
branch=context.branch,
61-
limit=limit,
62-
offset=offset,
63-
account=context.account_session,
64-
include_source=True,
65-
include_owner=True,
66-
partial_match=partial_match,
67-
)
54+
objs = []
55+
if edges or "hfid" in filters:
56+
objs = await NodeManager.query(
57+
db=db,
58+
schema=cls._meta.schema,
59+
filters=filters or None,
60+
fields=node_fields,
61+
at=context.at,
62+
branch=context.branch,
63+
limit=limit,
64+
offset=offset,
65+
account=context.account_session,
66+
include_source=True,
67+
include_owner=True,
68+
partial_match=partial_match,
69+
)
6870

6971
if "count" in fields:
7072
if filters.get("hfid"):

changelog/4454.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix performance issue for GraphQL queries that only count nodes.

0 commit comments

Comments
 (0)