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

Function countRowsTenantBounded

apps/sim/lib/table/rows/service.ts:944–949  ·  view source on GitHub ↗

* `COUNT(*)` for a filtered view, kept inside the tenant's rows: measured * 12.7s → 1.0s counting a rare ILIKE filter on a 1M-row table inside a 12M-row * relation (see withSeqscanOff for why the planner gets this wrong).

(whereClause: SQL | undefined)

Source from the content-addressed store, hash-verified

942 * relation (see {@link withSeqscanOff} for why the planner gets this wrong).
943 */
944async function countRowsTenantBounded(whereClause: SQL | undefined): Promise<number> {
945 return withSeqscanOff(async (trx) => {
946 const [result] = await trx.select({ count: count() }).from(userTableRows).where(whereClause)
947 return Number(result.count)
948 })
949}
950
951export async function queryRows(
952 table: TableDefinition,

Callers 1

queryRowsFunction · 0.85

Calls 1

withSeqscanOffFunction · 0.90

Tested by

no test coverage detected