Changes between Initial Version and Version 4 of Ticket #2306


Ignore:
Timestamp:
Jul 10, 2006, 9:36:35 PM (18 years ago)
Author:
Adrian Holovaty
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #2306

    • Property Cc mir@… added
    • Property Status newassigned
  • Ticket #2306 – Description

    initial v4  
    33Given a room r, asking Django to evaluate r.photos.all() runs an explicit join:
    44
    5 SELECT `kords3_photo`.`id`,`kords3_photo`.`image` FROM `kords3_photo` LEFT OUTER JOIN `kords3_room_photos` AS `m2m_kords3_photo__room` ON `kords3_photo`.`id` = `m2m_kords3_photo__room`.`photo_id` WHERE (`m2m_kords3_photo__room`.`room_id` = 1) ORDER BY `kords3_photo`.`image` ASC
     5{{{
     6SELECT `kords3_photo`.`id`,`kords3_photo`.`image`
     7FROM `kords3_photo`
     8LEFT OUTER JOIN `kords3_room_photos` AS `m2m_kords3_photo__room`
     9ON `kords3_photo`.`id` = `m2m_kords3_photo__room`.`photo_id`
     10WHERE (`m2m_kords3_photo__room`.`room_id` = 1)
     11ORDER BY `kords3_photo`.`image` ASC
     12}}}
    613
    714which takes around 1 second, when the same query rewritten as an implicit join:
    815
    9 SELECT `kords3_photo`.`id`,`kords3_photo`.`image` FROM `kords3_photo` , `kords3_room_photos` WHERE `kords3_photo`.`id` = `kords3_room_photos`.`photo_id` AND `kords3_room_photos`.`room_id` = 1 ORDER BY `kords3_photo`.`image` ASC
     16{{{
     17SELECT `kords3_photo`.`id`,`kords3_photo`.`image`
     18FROM `kords3_photo` , `kords3_room_photos`
     19WHERE `kords3_photo`.`id` = `kords3_room_photos`.`photo_id`
     20AND `kords3_room_photos`.`room_id` = 1
     21ORDER BY `kords3_photo`.`image` ASC
     22}}}
    1023
    1124would take under a millisecond.
Back to Top