Fixes https://github.com/payloadcms/payload/issues/10810 This was caused by using `COUNT(*)` aggregation instead of `COUNT(DISTINCT table.id)`. However, we want to use `COUNT(*)` because `COUNT(DISTINCT table.id)` is slow on large tables. Now we fallback to `COUNT(DISTINCT table.id)` only when `COUNT(*)` cannot work properly. Example of a query that leads to incorrect `totalDocs`: ```ts const res = await payload.find({ collection: 'directors', limit: 10, where: { or: [ { movies: { equals: movie2.id, }, }, { movies: { equals: movie1.id, }, }, { movies: { equals: movie1.id, }, }, ], }, }) ```
Payload Drizzle Adapter
The Drizzle package is used by db-postgres and db-sqlite for shared functionality of SQL databases. It is not meant to be used directly in Payload projects.