Skip to content

Commit eeaa857

Browse files
authored
fix(perf): use more optimal subquery (#23)
1 parent f8a1911 commit eeaa857

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,13 @@ const makeUtils = (
191191
)} = ${myAlias}.${sql.identifier(otherAttr.name)}`;
192192
},
193193
);
194-
const subquery = sql.fragment`(select ${fragment} from ${sql.identifier(
194+
const subquery = sql.fragment`exists (select 1 from ${sql.identifier(
195195
relevantColumn.class.namespaceName,
196196
relevantColumn.class.name,
197197
)} as ${myAlias} where (${sql.join(
198198
relationConditions,
199199
") and (",
200-
)})) is true`;
200+
)}) and (${fragment}))`;
201201
queryBuilder.where(subquery);
202202
} else {
203203
queryBuilder.where(fragment);

0 commit comments

Comments
 (0)