From b514f07ef34e9fbbb447d090b8160b1463f5520d Mon Sep 17 00:00:00 2001 From: Lucas Guillermou Date: Fri, 21 Mar 2025 12:13:39 +0100 Subject: [PATCH] Remove hfid in upsert payload --- changelog/upsertperformances.changed.md | 1 + infrahub_sdk/node.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelog/upsertperformances.changed.md diff --git a/changelog/upsertperformances.changed.md b/changelog/upsertperformances.changed.md new file mode 100644 index 00000000..cae7b40e --- /dev/null +++ b/changelog/upsertperformances.changed.md @@ -0,0 +1 @@ +Improve node upsert performances diff --git a/infrahub_sdk/node.py b/infrahub_sdk/node.py index 864abf1c..a7ee537f 100644 --- a/infrahub_sdk/node.py +++ b/infrahub_sdk/node.py @@ -1418,8 +1418,10 @@ async def create( ) -> None: mutation_query = self._generate_mutation_query() + # Upserting means we may want to create, meaning payload contains all mandatory fields required for a creation, + # so hfid is just redondant information. Currently, upsert mutation has performance overhead if `hfid` is filled. if allow_upsert: - input_data = self._generate_input_data(exclude_hfid=False, request_context=request_context) + input_data = self._generate_input_data(exclude_hfid=True, request_context=request_context) mutation_name = f"{self._schema.kind}Upsert" tracker = f"mutation-{str(self._schema.kind).lower()}-upsert" else: