Phil Bookst
09/26/2021, 10:04 AMmodel Profile {
id String? @unique
username String @id
is_private Boolean?
is_verified Boolean?
full_name String?
biography String?
profile_pic_url String?
post_amount Int?
follower Int?
following Int?
imageTags ImageTags[]
nodes Image[] // this is the slow relation
SearchProfiles SearchProfiles[]
@@map("profile")
}
model Image {
id String @id
thumbnail String
shortcode String @unique
liked Int
comment_count Int
engagement_rate Float?
day Int?
hour Int?
date String
caption String?
profile Profile? @relation(fields: [profileUsername], references: [username])
profileUsername String?
hashtag Hashtag? @relation(fields: [hashtagName], references: [name])
hashtagName String?
location Location? @relation(fields: [locationId], references: [id])
locationId String?
imageHashtags ImageHashtags[]
imageTags ImageTags[]
imageLocations ImageLocations[]
@@map("image")
}
if i run this query, it takes about 4-5 seconds to give me the results
const user = await prisma.profile.findUnique({
where: {
username,
},
include: {
nodes: true,
},
});
if i run it without the include it takes around 200ms
const user = await prisma.profile.findUnique({
where: {
username,
},
});
the profile table has around 370k entries and and image table around 620k