John Cantrell
03/02/2022, 1:01 PMJohn Cantrell
03/02/2022, 1:01 PMJohn Cantrell
03/02/2022, 1:16 PMJohn Cantrell
03/02/2022, 2:27 PMMotdde
03/02/2022, 8:44 PMBEGIN
and nothing more.Will King
03/02/2022, 10:30 PMmodel Dish {
...
}
model Plan {
...
monday Dish[]
tuesday Dish[]
wednesday Dish[]
thursday Dish[]
...
}
Nditah Samweld
03/05/2022, 11:34 AMconst countries = await prisma.locationCountry.createMany({
data: countryArray,
skipDuplicates: true,
});
Country has 250 records and it loads well. States and Cities record break along the line. Is there a limit to records that can be seeded in Nestjs + Prisma ?Nditah Samweld
03/05/2022, 1:15 PMMischa
03/08/2022, 4:44 PMgroupBy
with _count: {distinct: {foo: true}}
?
would like to group by DISTINCT someColumnforeverjunior
03/09/2022, 2:03 PMSean Sullivan
03/09/2022, 6:35 PMmodel User {
id Int @id @default(autoincrement())
primaryEmail String @unique @map("primary_email")
emails Email[]
@@map("users")
}
model Email {
id Int @id @default(autoincrement())
userId Int @map("user_id")
user User @relation(fields: [userId], references: [id])
email String @unique
@@map("emails")
}
And I'd like to get all users who don't have an email, per the docs, I'm running:
prisma.user.findMany({
where: { emails: { none: {} } }
});
This creates SQL along the lines of:
SELECT * FROM users
WHERE (users.id) NOT IN (
SELECT users.id
FROM users
INNER JOIN emails
ON (emails.user_id) = (users.id)
WHERE (users.id IS NOT NULL)
)
The query plan for this
EXPLAIN SELECT * FROM users
WHERE (users.id) NOT IN (
SELECT users.id
FROM users
INNER JOIN emails
ON (emails.user_id) = (users.id)
WHERE (users.id IS NOT NULL)
);
QUERY PLAN
----------------------------------------------------------------------------------------------
Seq Scan on users (cost=2057.26..59509346.61 rows=24028 width=26)
Filter: (NOT (SubPlan 1))
SubPlan 1
-> Materialize (cost=2057.26..4394.34 rows=55777 width=4)
-> Hash Join (cost=2057.26..3897.46 rows=55777 width=4)
Hash Cond: (emails.user_id = users_1.id)
-> Seq Scan on emails (cost=0.00..1069.77 rows=55777 width=4)
-> Hash (cost=1268.56..1268.56 rows=48056 width=4)
-> Seq Scan on users users_1 (cost=0.00..1268.56 rows=48056 width=4)
Filter: (id IS NOT NULL)
(10 rows)
is prohibitively expensive to run because it materializes a table of all users who have emails and then scans it for each row in users. Our users table is relatively small (~52,000 rows) but these queries take forever (i.e. they don't terminate) and started clogging up our db connection pool. I can write a handwritten query that joins a table of all users without an email that runs almost instantly.
I'm wondering if there is an explanation for this behavior so I can understand and avoid it in the future, or if this is sub-optimal performance that could be fixed with a PR?Sean Sullivan
03/09/2022, 6:54 PMOle Christian
03/10/2022, 2:56 PM#15 1.154 ==[ @xxx/some-module ]======================================[ 3 of 11 ]==
#15 5.338 "@xxx/some-module" completed successfully in 4.25 seconds.
#15 5.338 Error: Unable to require(`/build/common/temp/node_modules/.pnpm/prisma@3.7.0/node_modules/prisma/libquery_engine-rhel-openssl-1.1.x.so.node`)
#15 5.338 /build/common/temp/node_modules/.pnpm/prisma@3.7.0/node_modules/prisma/libquery_engine-rhel-openssl-1.1.x.so.node: ELF load command past end of file
This seem to happen randomly, and in different modules requiring prisma.
bash-4.4# /build/common/temp/node_modules/.bin/prisma2 -v
prisma : 3.7.0
@prisma/client : 3.7.0
Current platform : rhel-openssl-1.1.x
Query Engine (Node-API) : libquery-engine 8746e055198f517658c08a0c426c7eec87f5a85f (at common/temp/node_modules/.pnpm/@prisma+engines@3.7.0-31.8746e055198f517658c08a0c426c7eec87f5a85f/node_modules/@prisma/engines/libquery_engine-rhel-openssl-1.1.x.so.node)
Migration Engine : migration-engine-cli 8746e055198f517658c08a0c426c7eec87f5a85f (at common/temp/node_modules/.pnpm/@prisma+engines@3.7.0-31.8746e055198f517658c08a0c426c7eec87f5a85f/node_modules/@prisma/engines/migration-engine-rhel-openssl-1.1.x)
Introspection Engine : introspection-core 8746e055198f517658c08a0c426c7eec87f5a85f (at common/temp/node_modules/.pnpm/@prisma+engines@3.7.0-31.8746e055198f517658c08a0c426c7eec87f5a85f/node_modules/@prisma/engines/introspection-engine-rhel-openssl-1.1.x)
Format Binary : prisma-fmt 8746e055198f517658c08a0c426c7eec87f5a85f (at common/temp/node_modules/.pnpm/@prisma+engines@3.7.0-31.8746e055198f517658c08a0c426c7eec87f5a85f/node_modules/@prisma/engines/prisma-fmt-rhel-openssl-1.1.x)
Default Engines Hash : 8746e055198f517658c08a0c426c7eec87f5a85f
Studio : 0.445.0
Ole Christian
03/10/2022, 2:58 PMGarrett Tolbert
03/11/2022, 3:56 AMnext.js
middleware page. Has anyone encountered this before?Nditah Samweld
03/15/2022, 10:50 AMauto
is not a known function. #11771
https://github.com/prisma/prisma/issues/11771Lukáš Stuchlík
03/16/2022, 9:14 AMawait prisma.$transaction(async (prisma) => {
for (const entity of changed) {
await prisma.entity.update({
where: ...
data: ...
})
}
if (deleted.length) {
// soft delete
await prisma.entity.updateMany({
where: ...,
data: {
deleted: true,
}
})
}
if (created.length) {
await prisma.entity.createMany({
data: created,
})
}
logResult(...)
})
The transaction itself works (it's used this way in many different entities and they pass alright), but in a few that seem to run much longer than other, I'm getting an exception: PrismaClientKnownRequestError: Transaction API error: Transaction already closed: Transaction is no longer valid. Last state: 'Expired'.
What can I do about it, or what causes it?David Marr
03/18/2022, 3:28 PMcreateMany
does not exist. Anyone know what might be the issue there?
const providers = await prisma.provider.createMany({
data: [
{ name: "Twitter" },
{ name: "Github" },
{ name: "YouTube" }
]
});
Salvador Lopez Mendoza
03/18/2022, 5:29 PM@map
doesn’t work for enums? Is this a known limitation? I have a enum defined as
enum DriverStatus {
OnDuty @map("ON_DUTY")
OffDuty @map("OFF_DUTY")
Disabled @map("DISABLED")
@@map("driver_status_enum")
}
But the generated typescript enum is
export const DriverStatus: {
OnDuty: 'OnDuty',
OffDuty: 'OffDuty',
Disabled: 'Disabled'
};
I would expect it to be
export const DriverStatus: {
OnDuty: 'ON_DUTY',
OffDuty: 'OFF_DUTY',
Disabled: 'DISABLED'
};
David Marr
03/19/2022, 7:35 PMActivity
model, that has a relation field to Provider
. I'm stuck at the very beginning trying this:
const stars = await getActivity();
await prisma.activity.upsert({
where: {
providerId: 2
}
});
Simon Vrachliotis
03/20/2022, 9:14 PMmiddleware
?
https://www.prisma.io/docs/concepts/components/prisma-client/middleware
Sounds like the perfect thing to integrate 3rd party APIs before/after a DB operation.Mischa
03/21/2022, 8:58 AM"dbName"
is null
if it's not defined, or isReadOnly
is false
if not defined, isNullable
is false
if not specified, etc
I have a modest DB schema and my DMMF string is like 7MB. I believe it would be able to get it a lot smaller if we assume missing values are `false`/`null`. Is this a possibility?
I'm willing to open a PR I just need a little guidance on this. My job is to make my application go faster and this appears to be at least one of the bottlenecks. More details are in that issue I linked.Mischa
03/21/2022, 8:59 AMMischa
03/21/2022, 12:18 PMcargo build
in prisma-engines
- do I need to specify my locally built library in PRISMA_QUERY_ENGINE_LIBRARY
when running npx prisma generate
?
If I pass in the query engine dylib that got built:
[db:generate] Error: Unable to require(`/Users/cyber/dev/prisma-engines/target/debug/libquery_engine.dylib`)
[db:generate] Invalid or unexpected token
[db:generate] npm ERR! Lifecycle script `generate` failed with error:
I want to test my changes to DMMF generation locally and am not clear on how to do thisDavid Marr
03/21/2022, 3:40 PMcreateMany
with a set of data that may have duplicates in the db (based on two non-@id fields)Clement Fradet Normand
03/25/2022, 11:55 AMYaakov
03/27/2022, 7:05 PMprisma.$transaction(async (prisma) => {
const user = await prisma.user.update({
where: {
id: 1,
},
data: {
name: 'Bob'
},
});
// How can I view the user's original name before the current update?
return user;
});
Chris Kihneman
03/29/2022, 8:46 PMupdateMany
really only seems to handle one data change on multiple records. What I really need is something like createMany
, where you can prep lots of updates for many records, then execute them all at once.
I take it the only real option to speed things up is batching inside of a transaction? In sets of like 10 or so?
await prisma.$transaction([
prisma.table.update({ where: { id: id1 }, data: { field: field1 }),
prisma.table.update({ where: { id: id2 }, data: { field: field2 }),
prisma.table.update({ where: { id: id3 }, data: { field: field3 }),
...
])
Luisfer
03/29/2022, 10:35 PMcidr
data type anytime soonLuisfer
03/29/2022, 10:35 PM