Loading
Current section: Query Optimization 4 exercises
Problem

Optimizing Query Performance with Indexes in Prisma

Transcript

00:00 For this exercise, we're going to be optimizing a query of the notes by a owner ID. And you're gonna be adding an index for foreign keys to all of the models that have foreign keys, where those foreign keys are not unique. If they're unique, they already have an index that was created for us by Prisma.

00:19 But if they're not unique, then we need to add an index. So your job is to first understand what's going on. And so you're gonna be using explain query, whether that's using SQLite 3 or the script file that I showed you how to do. And once you understand what's going on there and you're seeing the scan in there and all that stuff,

00:38 then you're gonna add the index and do the explain again and make sure that scan does not show up and that we can use that index. And this we're gonna do so we can keep our queries really fast. So give that a whirl and we'll see you when you're done.