fix(catalog-backend): split queryEntities list and count queries
The filtered CTE was referenced twice (count + data), preventing Postgres 12+ from inlining it. This forced full materialization of the filtered set before LIMIT could short-circuit. Split into two separate queries run via Promise.all so the list CTE is only referenced once and the planner can short-circuit on LIMIT. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-catalog-backend': patch
|
||||
---
|
||||
|
||||
Split the `queryEntities` list and count into separate queries instead of a multi-reference CTE. When the `filtered` CTE was referenced twice (once for the count, once for the data), PostgreSQL refused to inline it, forcing full materialization of the filtered set before applying `LIMIT`. By running the count as a standalone query, the list CTE is only referenced once, allowing the planner to short-circuit on `LIMIT` and return the first page in milliseconds instead of waiting for the full filtered set to materialize.
|
||||
Reference in New Issue
Block a user