Consider this query:
q
.from({ issue: issuesCollection })
.join(
{
users: q
.from({ user: usersCollection })
.where(({ user }) => eq(user.status, `active`))
.orderBy(({ user }) => user.name, `asc`)
.limit(1),
},
({ issue, users }) => eq(issue.userId, users.id),
`left`
)
It joins with a subquery that returns a single user. So the results of the query should only ever contain that one user. However, the optimized version of this query doesn't take into account the limit on the subquery and the resulting rows are joined with all users.
Consider this query:
It joins with a subquery that returns a single user. So the results of the query should only ever contain that one user. However, the optimized version of this query doesn't take into account the limit on the subquery and the resulting rows are joined with all users.