perf(db-postgres): skip pagination overhead if limit: 0 is passed (#12261)

This improves performance when querying data in Postgers / SQLite with
`limit: 0`. Before, unless you additionally passed `pagination: false`
we executed additional count query to calculate the pagination. Now we
skip this as this is unnecessary since we can retrieve the count just
from `rows.length`.

This logic already existed in `db-mongodb` -
1b17df9e0b/packages/db-mongodb/src/find.ts (L114-L124)
This commit is contained in:
Sasha
2025-04-30 19:31:04 +03:00
committed by GitHub
parent 564fdb0e17
commit 27d644f2f9

View File

@@ -46,6 +46,7 @@ export const findMany = async function find({
const offset = skip || (page - 1) * limit
if (limit === 0) {
pagination = false
limit = undefined
}