Hi
I have a huge "Agents" table with many relations and a "Orders" table
with agent field related via r_agent to Agents.
When I filter like orders.r_agent.has(Agents.name.ilike("test")) the
query is too slow.
I came up with creating a view "Agents_small" on the database Agents
table whith only a few fields and no relations, ending up with two
relations on the Orders table like the following:
sqorm.mapper(Order, self.orders_table, properties = {
'r_agent' : sqorm.relation(Agents,
...
lazy=False, uselist=False, cascade="none"),
'r_agent_small' : sqorm.relation(Agents_small,
...
foreign_keys=self.orders_table.c.agent,
lazy=False, uselist=False, cascade="none"),
Now i can use the r_agent_small relation when I have to partialize and
it is really faster. I use the r_agent when I have to load all related
attributes.
Is this solution a good one? Should I do something different inside
sqlAlchemy instead?
thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---