Minor perf improvement to queryEntities when limit=0

Updates queryEntities to not execute dbQuery at all when limit is 0

Signed-off-by: Brian Hudson <brian.r.hudson@gmail.com>
This commit is contained in:
Brian Hudson
2024-01-24 10:25:03 -05:00
parent 086294bda1
commit 89b674c1e5
2 changed files with 6 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-backend': patch
---
Minor performance improvement for queryEntities when the limit is 0.
@@ -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