> Is this the most efficient way to do this, or am I over-complicating it?
That roughly looks like code that I've implemented in the past.
If it works and you don't have issues, I wouldn't worry about efficiency. Stuff like this will often vary based on the underlying table data - the structure, size, etc. Adding indexes on columns can often improve performance a lot.
If you're really concerned on optimizing this, the typical approach is to focus on generating the target SQL query that works within the performance constraints you want, and then porting it to sqlalchemy by writing python code that will generate that same output.