schettn
schettn
PPrisma
Created by schettn on 11/27/2024 in #help-and-questions
`isNot: null` filter on relation does not work
Right?
8 replies
PPrisma
Created by schettn on 11/27/2024 in #help-and-questions
`isNot: null` filter on relation does not work
The issue is, although no routes have associated region, ‘routesData’ contains all routes. I thought that by providing ‘isNot: null’ to the relations, it will exclude all routes that have no region. In my case all of them. So I expect an empty array. The console log shows the relation of the first route which is null, thus this route should not be there.
8 replies
PPrisma
Created by schettn on 11/26/2024 in #help-and-questions
Prisma Studio crashes with large databases
The root cause is that Prisma Studio loads every record of relations into its RecordStore
22 replies
PPrisma
Created by schettn on 11/26/2024 in #help-and-questions
Prisma Studio crashes with large databases
No description
22 replies
PPrisma
Created by schettn on 11/26/2024 in #help-and-questions
Prisma Studio crashes with large databases
No description
22 replies
PPrisma
Created by schettn on 11/26/2024 in #help-and-questions
Prisma Studio crashes with large databases
@Nurul I have reverse engineered the issue. Take a look at the following code:
r.select = l.reduce((e, t) => {
console.log(e,t)


if (!t) return e;
if (t.isList && t.isRelation) {
const s = t.getRelationIDFieldName;

e[t.name] = !s || { select: { [s]: !0 } };
} else e[t.name] = !0;
return e;
}, {})
r.select = l.reduce((e, t) => {
console.log(e,t)


if (!t) return e;
if (t.isList && t.isRelation) {
const s = t.getRelationIDFieldName;

e[t.name] = !s || { select: { [s]: !0 } };
} else e[t.name] = !0;
return e;
}, {})
prisma studio used this to calculate the select. Normally it would use getRelationIDFieldName to get the primary keys of the relation. In my case i use compound primary keys like @@id([tripId, stopId, stopSequence, gtfsImportId]). With compound keys the getRelationIDFieldName returns null, it sets the relation to true instead using only the primary keys of the relation.
22 replies
PPrisma
Created by schettn on 11/26/2024 in #help-and-questions
Prisma Studio crashes with large databases
Is it a design decision that currently all relation data is fetched, or is it a "bug"? Because if the relations are only needed for the relation counts then a simple rewrite to this would do the trick:
const res = await client.gTFSImport.findMany({
select: {
_count: {
select: {
CalendarDate: true,
agencies: true,
calendars: true,
routes: true,
stopTimes: true,
stops: true,
tourismRegions: true,
trips: true,
},
},
},
skip: 0,
take: 100,
});
const res = await client.gTFSImport.findMany({
select: {
_count: {
select: {
CalendarDate: true,
agencies: true,
calendars: true,
routes: true,
stopTimes: true,
stops: true,
tourismRegions: true,
trips: true,
},
},
},
skip: 0,
take: 100,
});
22 replies
PPrisma
Created by schettn on 11/26/2024 in #help-and-questions
Prisma Studio crashes with large databases
Thanks
22 replies
PPrisma
Created by schettn on 11/26/2024 in #help-and-questions
Prisma Studio crashes with large databases
I think that prisma studio runs into memory problem when processing this large amout of data client side. So its not directly related to the response time. I calculated the total size of the query that is performed by Prisma Studio for the GTFSImport table (with relations):
Time taken: 8059ms
Size of res: 181.3017292022705 MB
Time taken: 8059ms
Size of res: 181.3017292022705 MB
22 replies
PPrisma
Created by schettn on 11/26/2024 in #help-and-questions
Prisma Studio crashes with large databases
No description
22 replies
PPrisma
Created by schettn on 11/26/2024 in #help-and-questions
Prisma Studio crashes with large databases
How is this possible? The "Fields" filter only hides the UI elements
22 replies
PPrisma
Created by schettn on 11/26/2024 in #help-and-questions
Prisma Studio crashes with large databases
Querying only the stoptimes takes about 7 seconds. But the StopTimes works well in Prisma Studio
22 replies
PPrisma
Created by schettn on 11/26/2024 in #help-and-questions
Prisma Studio crashes with large databases
Hi @Nurul I ran the query inside my service:
// Track time
const start = Date.now();

const res = await client.gTFSImport.findMany({
select: {
CalendarDate: true,
agencies: true,
calendars: true,
date: true,
id: true,
routes: true,
stopTimes: true,
stops: true,
tourismRegions: true,
trafficRegions: true,
trips: true,
},
skip: 0,
take: 100,
});

const end = Date.now();

console.log("Time taken: ", end - start);
// Track time
const start = Date.now();

const res = await client.gTFSImport.findMany({
select: {
CalendarDate: true,
agencies: true,
calendars: true,
date: true,
id: true,
routes: true,
stopTimes: true,
stops: true,
tourismRegions: true,
trafficRegions: true,
trips: true,
},
skip: 0,
take: 100,
});

const end = Date.now();

console.log("Time taken: ", end - start);
Time taken: 8155ms
Time taken: 8155ms
So its about 8 seconds. Should Prisma Studio crash in this timeframe?
22 replies
PPrisma
Created by schettn on 11/26/2024 in #help-and-questions
Prisma Studio crashes with large databases
No description
22 replies
PPrisma
Created by schettn on 11/26/2024 in #help-and-questions
Prisma Studio crashes with large databases
No description
22 replies
PPrisma
Created by schettn on 11/26/2024 in #help-and-questions
Prisma Studio crashes with large databases
Strangly it only crashes when I open the GTFSImport model (contains only 1 row). Opening all other models works.
22 replies
PPrisma
Created by schettn on 9/16/2024 in #help-and-questions
Lazy load query engine in Cloudflare Workers
Btw: Please add a "Other" flag to the Discord posts. I always have to add a incorrect tag in order to ask something.
3 replies
PPrisma
Created by schettn on 7/12/2024 in #help-and-questions
How to use getDMMF
Update: @prisma/internals seems to work. @prisma/sdk does not
6 replies
PPrisma
Created by schettn on 7/12/2024 in #help-and-questions
How to use getDMMF
Setting the cwd also does not change anything.
const dmmf = await getDMMF({
cwd: process.cwd(),
datamodelPath: path.join(PYLON_ABSOLUTE_PATH, 'prisma/schema.prisma')
})
const dmmf = await getDMMF({
cwd: process.cwd(),
datamodelPath: path.join(PYLON_ABSOLUTE_PATH, 'prisma/schema.prisma')
})
6 replies
PPrisma
Created by schettn on 7/12/2024 in #help-and-questions
How to use getDMMF
The query-engine exists under the following path: packages/pylon-server/studio-pylon/node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node
6 replies