#46 too many DB selects in person.addresses case

closed-wont-fix
None
5
2008-03-07
2004-10-05
No

I see the same number of queries as Robert
Marcin

http://sourceforge.net/mailarchive/message.php?msg_id=9673722

>> First about MultipleJoin: as Robert wrote in
>>
http://sourceforge.net/mailarchive/forum.php?thread_id=5435228&forum_id=30269

>>
>> person.addresses will generate n+1 queries to DB.
>
>
> I don"t think that is what happens...? It"s
certainly not intended to
> cause that many selects.

Unfortunately, it does, at least it does when using
Postgres, a fresh install of
SQLObject 0.6, Python 2.3.3, W2000 :-(

The first select is :

SELECT id FROM address WHERE person_id = ###

which returns "n" id"s

then for every id in the returned list there is :

SELECT column(s)... FROM address WHERE id = ####

i.e. n+1 queries to DB.

Robert

Discussion

  • Garrett Smith

    Garrett Smith - 2006-02-05

    Logged In: YES
    user_id=448609

    Based on the code, this behavior appears very much by design.

    I recommend turning MultipleJoin into a descriptor that
    implements a standard select, which would avoid the multiple
    calls to the DB.

     
  • Oleg Broytman

    Oleg Broytman - 2008-03-07
    • assigned_to: nobody --> phd
    • status: open --> closed-wont-fix
     
  • Oleg Broytman

    Oleg Broytman - 2008-03-07

    Logged In: YES
    user_id=4799
    Originator: NO

    Use SQLMultipleJoin.

     

Log in to post a comment.