[SQLObject] eagerly fetching joined objects
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Simon L. <sl...@re...> - 2011-07-21 00:22:30
|
Hi, I'm currently trying to improve my DB performance by reducing the number of queries and associated overhead while grabbing some SQLObjects from the DB. I would like to have SQLObject fully populate the object graph for the objects I'm using since all joined objects will be read every time this object is loaded. Here are prototypes for my objects class A (SQLObject): x = IntCol() bees = MultipleJoin('B', joinColumn = 'a_id', orderBy='display_order') cees = MultipleJoin('C', joinColumn = 'a_id', orderBy='display_order') class B (SQLObject): y = IntCol() display_order = IntCol() dees = MultipleJoin('D', joinColumn = 'b_id') a = ForeignKey('A') class C (SQLObject): z = IntCol() display_order = IntCol() a = ForeignKey('A') class D (SQLObject): m = IntCol() b = ForeignKey('B') Is there any way using SQLObject I can reduce the number of queries from 1+(1+count_b) + (1+count_c) +(1+count_d)*count_b to something closer to 1 query? Thanks in advance, Simon |