Re: [sqlalchemy] Queries Across 13 Models - How to improve efficiency?

2023-01-27 Thread Simon King
It looks like all your models share the same "id" value - is that right? If so, you ought to be able to load all of them in a single query, something like this (untested): def getmodels(dbsession, id): models = [M1, M2, M3] conditions = [(M.id == id) for M in models] instances =

[sqlalchemy] Queries Across 13 Models - How to improve efficiency?

2023-01-26 Thread Shuba
Hi! I have a web application whose main feature is to query 13 different database tables when the user performs a search. I'm performing the query like this: https://gist.github.com/bmare/8c11ba6efcb97ba14dc30bc260aebc6c , and I'm wondering if there is a better method. I like having all the