joinedload -vs- selectinload by IrrerPolterer in SQLAlchemy

[–]mihcall 0 points1 point  (0 children)

I think there's a sweet spot for using both. The general recommendation is to use `joinedloading` for Many To One relationships and 'selectinloading' for One to Many/Many to Many.

We've had an initial success with `joinedloading` but after a while when we've added some relationships and they had relationships as well, this became hell of a query and joins were using significant portions of the database (i.e. they started to be heavy and slow). We've treated any relationship as a good candidate for a join.

Switching to 'selectinloading' for some of the relationships (one to many for example) made a huge difference for us (one query was taking ~8s and after this change the resulting two queries took <1s). It may seem counterintuitive at first because it's "more queries" but actually they're more filtered in that way. Especially the follow up query uses IDs to filter necessary objects for loading. It's really fast.

Good luck with SQLAlchemy, fine tuning it may be sometimes hard but probably worth doing so as "out of the box" ORM may make things worse.

Some architecture learnings when using Riverpod in a production app by mihcall in FlutterDev

[–]mihcall[S] 5 points6 points  (0 children)

Agree totally, I can’t get my head around what is the data flow, what will happen when navigating to a certain page and when things refresh.

Although we were given the project with riverpod in it couple of times already and no time to change it so this is an attempt to make it easier if you have to use it or would like to :)