fix(catalog-backend): simplify facets COUNT(DISTINCT) to COUNT(*)
The UNIQUE constraint on (entity_id, key, value) from the search indices migration guarantees each entity appears at most once per (key, original_value) group, making DISTINCT unnecessary. Removing it lets the database use a simpler aggregation plan. 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:
@@ -685,7 +685,7 @@ export class DefaultEntitiesCatalog implements EntitiesCatalog {
|
||||
.select({
|
||||
facet: 'search.key',
|
||||
value: 'search.original_value',
|
||||
count: this.database.raw('count(DISTINCT search.entity_id)'),
|
||||
count: this.database.raw('count(*)'),
|
||||
})
|
||||
.groupBy(['search.key', 'search.original_value']);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user