I don’t know of a way to do that more efficiently.
I know some folks don’t like to use the built-in row ids and instead create their own ‘id’ columns, and maybe this is one reason why. If you restructured your tables that way, you could get all the rows in a single search
call to the database with an any
query on that ‘id’ column.
p.s. It would be easier to read your Python code excerpt if you format it properly as shown here: How to ask a good question