Changes between Initial Version and Version 4 of Ticket #2306
- Timestamp:
- Jul 10, 2006, 9:36:35 PM (18 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #2306
- Property Cc added
- Property Status new → assigned
-
Ticket #2306 – Description
initial v4 3 3 Given a room r, asking Django to evaluate r.photos.all() runs an explicit join: 4 4 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 {{{ 6 SELECT `kords3_photo`.`id`,`kords3_photo`.`image` 7 FROM `kords3_photo` 8 LEFT OUTER JOIN `kords3_room_photos` AS `m2m_kords3_photo__room` 9 ON `kords3_photo`.`id` = `m2m_kords3_photo__room`.`photo_id` 10 WHERE (`m2m_kords3_photo__room`.`room_id` = 1) 11 ORDER BY `kords3_photo`.`image` ASC 12 }}} 6 13 7 14 which takes around 1 second, when the same query rewritten as an implicit join: 8 15 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 {{{ 17 SELECT `kords3_photo`.`id`,`kords3_photo`.`image` 18 FROM `kords3_photo` , `kords3_room_photos` 19 WHERE `kords3_photo`.`id` = `kords3_room_photos`.`photo_id` 20 AND `kords3_room_photos`.`room_id` = 1 21 ORDER BY `kords3_photo`.`image` ASC 22 }}} 10 23 11 24 would take under a millisecond.