Ricardo Seromenho
04/20/2022, 3:10 PMOmar
04/20/2022, 3:29 PMRicardo Seromenho
04/20/2022, 3:34 PMRicardo Seromenho
04/20/2022, 4:29 PMNurul
04/21/2022, 1:17 PMOmar
04/21/2022, 9:11 PMRicardo Seromenho
04/22/2022, 9:16 AM...However, this advice doesn't apply as much to MySQL, because it was designed to handle connecting and disconnecting very efficiently and to respond to small and simple queries very quickly...
I'm not sure what small means but the query is indeed simple but i don't think it's small. It something like
SELECT foo FROM TABLE WHERE id IN (15 thousand id's here or more)
Ricardo Seromenho
04/22/2022, 9:16 AMmodel User {
id Int @id @default(autoincrement())
posts Post[]
}
model Post {
id Int @id @default(autoincrement())
author User @relation(fields: [authorId], references: [id])
authorId Int @map("author_id")// relation scalar field (used in the `@relation` attribute above)
}
Doing this raw query:
SELECT p.id, p.author_id FROM post p LEFT JOIN user u ON p.author_id = u.id
My question is, is there some method we could use from prisma to try to map the results to the schema? The goal have something like prisma does already eg:
result = [{id: 1, author: { id: 1 }} ]Omar
04/22/2022, 2:59 PMRicardo Seromenho
04/26/2022, 10:00 AMInvalid `prisma.foo.findMany()` invocation in
Can't reach database server at `...`:`5432`
Please make sure your database server is running at `...`:`5432`.
clientVersion: '3.9.2',
Just to make sure the query was ok and nothing wrong with it I added take: 5
and it works. Without the take: 5
it fails. I believe it's because the query being so big with thousands of records.Omar
04/26/2022, 10:26 PMNurul
04/27/2022, 10:28 AMtake
argument.
We would definitely like to fix this issue, would it be possible for you to provide us with a way so that we could reproduce this?Ricardo Seromenho
05/04/2022, 12:45 AMRicardo Seromenho
05/11/2022, 10:29 PMJacob Ley
05/11/2022, 10:55 PMfind()
method has already been solved by tools like Sequelize and Knex.
Breaking “complex” queries into N “simple” queries is a great way to start blowing up your database/connections in an attempt to avoid writing SQL. There is no way NodeJS/Go Filtering + Network serialization is faster/lower resource than native SQL on Postgres/MySQL
If a query is too complicated to be implemented in a single SQL call, I can always take the step of splitting up my find()
calls manually.
But when I explicitly want to combine a couple JOINS
(like in that video linked, which returns only one result) it doesn’t seem like that is possible…
I’ll admit I currently have not implemented Prisma yet and have mostly investigated it as an alternative to Sequelize/TypeORM so please let me know if I am missing something.Nurul
05/12/2022, 7:49 AM