MCPcopy Index your code
hub / github.com/TanStack/db / removeRedundantSubqueries

Function removeRedundantSubqueries

packages/db/src/query/optimizer.ts:454–463  ·  view source on GitHub ↗

* Removes redundant subqueries that don't add value. * A subquery is redundant if it only wraps another query without adding * WHERE, SELECT, GROUP BY, HAVING, ORDER BY, or LIMIT/OFFSET clauses. * * @param query - The QueryIR to process * @returns A new QueryIR with redundant subqueries removed

(query: QueryIR)

Source from the content-addressed store, hash-verified

452 * @returns A new QueryIR with redundant subqueries removed
453 */
454function removeRedundantSubqueries(query: QueryIR): QueryIR {
455 return {
456 ...query,
457 from: removeRedundantFromClause(query.from),
458 join: query.join?.map((joinClause) => ({
459 ...joinClause,
460 from: removeRedundantJoinFromClause(joinClause.from),
461 })),
462 }
463}
464
465/**
466 * Removes redundant subqueries from a FROM clause.

Callers 2

optimizeQueryFunction · 0.85

Calls 3

mapMethod · 0.45

Tested by

no test coverage detected