PretendoNetwork / friends

Pretendo Network friends server
GNU Affero General Public License v3.0
27 stars 7 forks source link

[Enhancement]: Improve SQL queries #21

Closed jonbarrow closed 3 weeks ago

jonbarrow commented 1 month ago

Checked Existing

What enhancement would you like to see?

Currently our SQL queries are horribly unoptimized. In an effort to simplify code readability, we opted to make many smaller queries rather than use optimized queries which may be less readable.

This has caused issues such as connections being locked up and taking multiple seconds to request all data, and n+1 queries for friends lists as found by @wolfendale. This should be changed as soon as possible.

Any other details to share? (OPTIONAL)

This issue only exists until a draft PR is made. We should do an overhaul of the entire database system in one PR to address these issues. Maybe we shouldn't raw-dog SQL anymore? I know ORMs and query builders can make queries more readable, but they also notoriously make bad SQL queries.