DT
Drizzle Team•8mo ago
Fyzz

Turso DB reads (alot)

Using turso for a project with drizzle ( I usually use mysql ), and i'm getting way more database reads than I should. Not sure if its something I did wrong or if there is a better way to to relational reads with sqlite than the relations() function built into the orm. Maybe I should just do a join instead. I guess what im asking is the best way to optimize reads when using drizzle + turso. I only have 3 tables. tokens, attributes, tokenAttributes (for many to many relationship) and all the reads in the screenshot from from 1 hour on local development
No description
3 Replies
Startup Spells 🪄 Newsletter Guy
it shouldnt happen like this. try logging your queries to see which one run a lot. turso should show it in ui. at least planetscale used to. but still this shouldnt happen. definitely do join. drizzle sends 1 query only & performs joins well. i even joined 3 tables lol. bdw, check if you are setting index or not. indexes are very important to get results fast. https://github.com/deadcoder0904/easypanel-nextjs-sqlite (see im using some best practices here but the schema is small enough but u can ask me as i have decent mid-sized project with a bit complex structure)
Aaroned
Aaroned•8mo ago
@Fyzz as @deadcoder0904 mentions indexes are very important. Without the right index, the database (inc. turso) will do a full table scan, and all the rows in the table will be "read" contributing to the "Rows Read" count.
Fyzz
FyzzOP•8mo ago
Thanks guys I’ll take a look
Want results from more Discord servers?
Add your server