Kay Khan
03/24/2022, 8:35 AMcreateMany
holding onto memory of the node.js application?
For more context i am looping overan array split into batches of 100k. And then inserting that 100k into the database. After each loop i notice a spike in the amount of memory the node.js application uses and it never drops (1gb, 2gb, 3gb etc). Overtime my script eventually runs out of memory
100% certain it seems like there is a memory leak in createManyAndrew Ross
03/24/2022, 9:52 AMDavid Marr
03/24/2022, 1:55 PMmigrate reset
be enough to apply that change?Slackbot
03/24/2022, 2:03 PMNathaniel Babalola
03/24/2022, 2:06 PMOrcioly Andrade Alves
03/24/2022, 4:12 PMimport { User } from '@prisma/client';
import { AppError } from '../shared/errors/AppError';
import prismaClient from '../prisma';
import { hash } from 'bcryptjs';
import { CreateUserDTO } from '../dtos/user/CreateUserDto';
class CreateUserService {
async execute({
name,
email,
password,
admin,
}: CreateUserDTO): Promise<User | undefined> {
const userAlreadyExists = await prismaClient.user.findUnique({
where: {
email,
},
});
if (userAlreadyExists) {
throw new AppError('Email address already used.');
}
const passwodHash = await hash(password, 8);
const user = await prismaClient.user.create({
data: {
name,
email,
password: passwodHash,
admin,
},
select: {
id: true,
name: true,
email: true,
admin: true,
created_at: true,
},
});
return user;
}
}
export { CreateUserService };
Justin Ellingwood
03/24/2022, 4:41 PMmatic
03/24/2022, 7:25 PMclient.challengeAttempt.findUnique({
where: { challengeId_userId: { challengeId: 'ac', userId: 'dc' } },
})
model ChallengeAttempt {
id String @id @default(cuid())
challenge Challenge @relation(fields: [challengeId], references: [id])
challengeId String
user User @relation(fields: [userId], references: [id])
userId String
@@unique([challengeId, userId])
}
My understanding is that querying a unique field should be almost instant while in our case the logs show that every day some queries need a couple of seconds (range from 200ms to 15s) to finish. We’ve also investigated that the payload is as small as it can be (and it’s small).
We are currently processing at most three concurrent requests every second and the CPU/memory of our server barely scratches the potential. DB, on the other hand, is quite bad and reaches the spike every day even though we have 2GB of RAM.
Apart from that, we are getting “Timeout fetching a new connection from the pool” even though the pool limit is 84 connections. (strangely, the logs show that there’s no active connection at all times)
I’ve also seen this review (https://github.com/edgedb/imdbench) and wanted to ask:
1. Is 2GB of RAM for a db for an app of our size too little?
2. Is this a common problem?
3. How do you cope with low performance?
At this point, we are considering switching to something else and help/feedback would be greatly appreciated 🙂Bret emm
03/24/2022, 8:56 PMMatthew
03/24/2022, 10:13 PMimport { PrismaClient } from '@prisma/client'
import { logger } from './logger'
const prisma: PrismaClient = new PrismaClient({
log: [
{
level: 'error',
emit: 'event',
},
]
})
prisma.$on('error', (e) => {
logger.error(e)
})
Matthew
03/24/2022, 10:13 PMsrc/prisma.ts:13:12 - error TS2345: Argument of type '"error"' is not assignable to parameter of type '"beforeExit"'.
Matthew
03/24/2022, 10:39 PMBen Guthrie
03/25/2022, 3:24 AMschema.prisma
and the generated migration sql. It looks like foreign key names are in the format of {tableName}_{field}_fkey
but I’m thinking we’d want the name to be something like {sourceTable}_{sourceField}_{targetTable}_{targetField}_fkey
to handle this case. Any thoughts on this? Should I submit an issue to prisma-engines?Eko Nur Arifin
03/25/2022, 7:09 AM'Customer & { addresses: Address[]; user: User; }'
but i think not flexible if have any change relation hopefully can use type like Prisma.CustomerInclude
but give error.
Type 'Customer & { addresses: Address[]; user: User; }' is not assignable to type 'CustomerInclude'.
thanks anyone helpHammadi Agharass
03/25/2022, 10:59 AMPanMan
03/25/2022, 11:02 AMwhere
, right? - https://www.prisma.io/docs/concepts/components/prisma-client/aggregation-grouping-summarizing#count-relations - eg, we can get all users with a count of posts, but we can’t get all users with a count of Published posts..Clement Fradet Normand
03/25/2022, 11:50 AMMatheus Assis
03/25/2022, 2:02 PMaetheryx
03/25/2022, 9:32 PMDELETE FROM ... RETURNING *
?Mischa
03/25/2022, 11:39 PMâžś platform git:(middleware) âś— npm ls @azure/identity <aws:tombo-dev>
platform@1.0.0 /Users/cyber/dev/platform
└─┬ platform-infra@0.1.0 -> ./packages/infra
└─┬ @prisma/migrate@3.11.1
└─┬ mssql@8.0.2
└─┬ tedious@14.4.0
└── @azure/identity@2.0.4
Demian N
03/26/2022, 3:21 AMEwan Lyon
03/26/2022, 7:25 AMAndré Brito Fonseca
03/26/2022, 11:48 AMid
(@id @default(uuid())
) and a code (an integer, unique).
If I invoke findUnique
and the where
references only the id, I get a message that is similar to this thread: https://stackoverflow.com/questions/65998680/prisma-findunique-where-takes-only-one-unique-argumentAndré Brito Fonseca
03/26/2022, 11:50 AMmodel Kind {
id String @id @default(uuid())
code String @unique
@@map("kind")
}
Adrian
03/26/2022, 12:53 PMAdrian
03/26/2022, 12:53 PMAdrian
03/26/2022, 12:54 PMEndyKaufman
03/26/2022, 4:16 PMNditah Samweld
03/27/2022, 7:58 AM[SOLVED]!
Please what's wrong with the Query?
Invalid `prisma.award.findMany()` invocation:
{
include: {
member: true,
organization: true
},
where: {
deleted: false,
member: 'cl0ebx5dy0424d6jxyfl14dsk'
~~~~~~~~~~~~~~~~~~~~~~~~~~~
},
orderBy: {
id: 'asc'
}
}
Philipp Minder
03/27/2022, 10:52 PM