diff --git a/.changeset/ninety-rules-sneeze.md b/.changeset/ninety-rules-sneeze.md new file mode 100644 index 0000000000..bea9d00f7e --- /dev/null +++ b/.changeset/ninety-rules-sneeze.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-backend': patch +--- + +Minor performance improvement for `queryEntities` when the limit is 0. diff --git a/plugins/catalog-backend/src/service/DefaultEntitiesCatalog.ts b/plugins/catalog-backend/src/service/DefaultEntitiesCatalog.ts index 0245fe1d4e..81982d5617 100644 --- a/plugins/catalog-backend/src/service/DefaultEntitiesCatalog.ts +++ b/plugins/catalog-backend/src/service/DefaultEntitiesCatalog.ts @@ -451,7 +451,7 @@ export class DefaultEntitiesCatalog implements EntitiesCatalog { countQuery.count('search.entity_id', { as: 'count' }); const [rows, [{ count }]] = await Promise.all([ - dbQuery, + limit > 0 ? dbQuery : [], // for performance reasons we invoke the countQuery // only on the first request. // The result is then embedded into the cursor