``` const v = await prisma.user.findMany({ wh...
# orm-help
y
Copy code
const v = await prisma.user.findMany({
    where: {id: {notIn: Array.from({length: 6000}, (v, idx) => idx.toString())}}
  })
  const total = await prisma.user.findMany({
    where: {}
  })
  console.log(v.length, total)
this should reproduct the problem.
r
@YErii 👋 Cannot reproduce this on the latest version of Prisma. I have 7 users and this is what I queried for and the response is correct:
Copy code
console.log(await prisma.user.findMany({ where: { id: { notIn: [1, 2] } } }))
Could you provide a sample repo?
y
`not in [1,2]`is not engough and you should provide at least 5000 items
because prisma split data into chunk and perchunk is 5000
you may try the code above and it will show you.
select xxx where xxx not in ($1,$2, ..., $5000)
+
select xxx where xxx not in ($1,$2, ..., $1000)
prisma will execute these 2 sql and merge the results which is not right.
total - 5000
+
total - 1000
is not equal with
total - 6000
r
Yes this is due to Prisma batching queries. A temporary workaround if you’re querying for so many items is setting this environment variable:
Copy code
QUERY_BATCH_SIZE=10000
So that it takes the amount of items you want to query in a batch. Also it would be great if you could persist this as an issue here.
y
Sure! But it is wierd that the
in
operator will not chunk items into 5000
and issue is opened here
👍 1
r
It will after you set the the
QUERY_BATCH_SIZE
y
even if i did not set the
QUERY_BATCH_SIZE
, the
In
operator and
NOT: {in: {xx}}
will not chunk and return the right result.
r
Yes but for larger records like 10000 it will chunk.
y
Got it and Looking forward to receiving the fixup soon.
✅ 1