* `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)
| 942 | * relation (see {@link withSeqscanOff} for why the planner gets this wrong). |
| 943 | */ |
| 944 | async 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 | |
| 951 | export async function queryRows( |
| 952 | table: TableDefinition, |
no test coverage detected