Skip to content

Commit 27d644f

Browse files
authored
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` - https://github.com/payloadcms/payload/blob/1b17df9e0ba43978c52e3f05fdab44c97bd29896/packages/db-mongodb/src/find.ts#L114-L124
1 parent 564fdb0 commit 27d644f

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

packages/drizzle/src/find/findMany.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export const findMany = async function find({
4646
const offset = skip || (page - 1) * limit
4747

4848
if (limit === 0) {
49+
pagination = false
4950
limit = undefined
5051
}
5152

0 commit comments

Comments
 (0)