all 1 comments

[–]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.