Fixing slow query
Hey guys, any idea why this query might suddenly take 9 seconds?
schema:
Maybe i need to add some indices?
7 Replies
adding some indexes...
solved
@@index([urlId, createdAt])
Thanks for letting us know that adding indexes resolved the issue! 😄 🙌
@Nurul yeah im learning that indexing is KEY! (pun intended haha)
Haha, I can totally relate to that 😄
If you work at prisma i would suggest adding more knowledge about indexing... it seems a lot of queries do a full table scan if there's not an index @Nurul... and you don't know this until you start to have 10k rows in a table - aka early production
Yes, I do work at Prisma 🙂
Thank you for the feedback, I'll definetely share it internally.
Did you had a chance to look at this series we did a while ago?
https://www.prisma.io/blog/improving-query-performance-using-indexes-1-zuLNZwBkuL
Prisma
Improving query performance with database indexes using Prisma: Int...
Learn the fundamentals of database indexes: what they are, the problem they solve, and their benefit and cost
no i didnt see it
thanks reading now