MCPcopy Index your code
hub / github.com/simstudioai/sim / selectPage

Function selectPage

apps/sim/lib/table/rows/ordering.ts:508–522  ·  view source on GitHub ↗
(executor: DbExecutor)

Source from the content-addressed store, hash-verified

506}): Promise<string[]> {
507 const { tableId, workspaceId, cutoff, filterClause, afterId, limit } = params
508 const selectPage = (executor: DbExecutor) =>
509 executor
510 .select({ id: userTableRows.id })
511 .from(userTableRows)
512 .where(
513 and(
514 eq(userTableRows.tableId, tableId),
515 eq(userTableRows.workspaceId, workspaceId),
516 lte(userTableRows.createdAt, cutoff),
517 afterId ? gt(userTableRows.id, afterId) : undefined,
518 filterClause
519 )
520 )
521 .orderBy(asc(userTableRows.id))
522 .limit(limit)
523 // A jsonb filter is unestimatable, so the planner would seq-scan the whole shared relation
524 // per page (12.6s measured) — keep it on the tenant's (table_id, id) index.
525 const rows = filterClause

Callers 2

selectRowIdPageFunction · 0.85
selectRowDataPageFunction · 0.85

Calls 1

eqFunction · 0.50

Tested by

no test coverage detected