From 7bab21f1ef2652f742f8464bc65f4a846ea794dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Tue, 19 May 2026 22:05:39 +0200 Subject: [PATCH] Remove redundant entity existence check in performStitching MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The initial SELECT entity_id FROM refresh_state check is redundant — the processedResult query in the Promise.all already handles the missing-entity case. This saves one database round trip per stitch. Co-Authored-By: Claude Opus 4.6 (1M context) Signed-off-by: Fredrik Adelöw --- .../src/database/operations/stitcher/performStitching.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/plugins/catalog-backend/src/database/operations/stitcher/performStitching.ts b/plugins/catalog-backend/src/database/operations/stitcher/performStitching.ts index 17cec3cf84..6929d3ca62 100644 --- a/plugins/catalog-backend/src/database/operations/stitcher/performStitching.ts +++ b/plugins/catalog-backend/src/database/operations/stitcher/performStitching.ts @@ -67,15 +67,6 @@ export async function performStitching(options: { let removeFromStitchQueueOnCompletion = true; try { - const entityResult = await knex('refresh_state') - .where({ entity_ref: entityRef }) - .limit(1) - .select('entity_id'); - if (!entityResult.length) { - // Entity does no exist in refresh state table, no stitching required. - return 'abandoned'; - } - // Selecting from refresh_state (with an optional left join to // final_entities for the previous hash) should yield exactly one row, // except in abnormal cases where the entity was deleted between the