killbasa / Amaneko

Discord bot for VTuber livestream relays and notifications.
https://docs.amaneko.ca/
MIT License
2 stars 0 forks source link

Database efficiency improvement #106

Open akuplace opened 7 months ago

akuplace commented 7 months ago

I believe that removing IDs on what should be weak entities should prove to help in an efficiency increase in the database by instead replacing them with composite primary keys.

An example would be:

model Subscription {
  id String @id @default(uuid()) // this is removed

  roleId                 String?
  discordChannelId       String?
  memberRoleId           String?
  memberDiscordChannelId String?

  relayChannelId String?
  cameoChannelId String?

  communityPostRoleId    String?
  communityPostChannelId String?

  channelId String
  channel   HolodexChannel @relation(fields: [channelId], references: [id], onDelete: Cascade)

  guildId String
  guild   Guild  @relation(fields: [guildId], references: [id], onDelete: Cascade)

  @@unique([channelId, guildId]) //replaced with @@id([channelId, guildId])
}
akuplace commented 7 months ago

I'm not very sure about this change so if someone could have a glance over it or test it out it would be extremely appreciated 🙇