EXPLAIN SELECT p.id, s.id FROM InMemoryDIASource AS p INNER JOIN ZoneZone AS zz FORCE INDEX (PRIMARY) ON p.zoneId = zz.zoneId INNER JOIN InMemoryObject AS s FORCE INDEX (idx_zone_ra) ON zz.matchZoneId = s.zoneId WHERE s.ra BETWEEN p.ra - zz.deltaRa AND p.ra + zz.deltaRa AND s.decl BETWEEN p.decl - 0.000833 AND p.decl + 0.000833 AND POW(p.x - s.x, 2) + POW(p.y - s.y, 2) + POW(p.z - s.z, 2) < 2.1137067679466e-10 \G *************************** 1. row *************************** id: 1 select_type: SIMPLE table: s type: ALL possible_keys: idx_zone_ra key: NULL key_len: NULL ref: NULL rows: 3044468 Extra: *************************** 2. row *************************** id: 1 select_type: SIMPLE table: p type: ALL possible_keys: idx_zone_ra key: NULL key_len: NULL ref: NULL rows: 30276 Extra: Using where *************************** 3. row *************************** id: 1 select_type: SIMPLE table: zz type: eq_ref possible_keys: PRIMARY key: PRIMARY key_len: 8 ref: serge.p.zoneId,serge.s.zoneId rows: 1 Extra: Using where EXPLAIN SELECT p.id, s.id FROM InMemoryDIASource AS p INNER JOIN ZoneZone AS zz FORCE INDEX (PRIMARY) ON p.zoneId = zz.zoneId INNER JOIN InMemoryObject AS s FORCE INDEX (idx_zone_ra) ON zz.matchZoneId = s.zoneId AND s.ra BETWEEN p.ra - zz.deltaRa AND p.ra + zz.deltaRa WHERE s.decl BETWEEN p.decl - 0.000833 AND p.decl + 0.000833 AND POW(p.x - s.x, 2) + POW(p.y - s.y, 2) + POW(p.z - s.z, 2) < 2.1137067679466e-10 \G *************************** 1. row *************************** id: 1 select_type: SIMPLE table: s type: ALL possible_keys: idx_zone_ra key: NULL key_len: NULL ref: NULL rows: 3044468 Extra: *************************** 2. row *************************** id: 1 select_type: SIMPLE table: p type: ALL possible_keys: idx_zone_ra key: NULL key_len: NULL ref: NULL rows: 30276 Extra: Using where *************************** 3. row *************************** id: 1 select_type: SIMPLE table: zz type: eq_ref possible_keys: PRIMARY key: PRIMARY key_len: 8 ref: serge.p.zoneId,serge.s.zoneId rows: 1 Extra: Using where EXPLAIN SELECT STRAIGHT_JOIN p.id, s.id FROM InMemoryDIASource AS p INNER JOIN ZoneZone AS zz FORCE INDEX (PRIMARY) ON p.zoneId = zz.zoneId INNER JOIN InMemoryObject AS s FORCE INDEX (idx_zone_ra) ON zz.matchZoneId = s.zoneId WHERE s.ra BETWEEN p.ra - zz.deltaRa AND p.ra + zz.deltaRa AND s.decl BETWEEN p.decl - 0.000833 AND p.decl + 0.000833 AND POW(p.x - s.x, 2) + POW(p.y - s.y, 2) + POW(p.z - s.z, 2) < 2.1137067679466e-10 \G *************************** 1. row *************************** id: 1 select_type: SIMPLE table: p type: ALL possible_keys: idx_zone_ra key: NULL key_len: NULL ref: NULL rows: 30276 Extra: *************************** 2. row *************************** id: 1 select_type: SIMPLE table: zz type: ref possible_keys: PRIMARY key: PRIMARY key_len: 4 ref: serge.p.zoneId rows: 323 Extra: *************************** 3. row *************************** id: 1 select_type: SIMPLE table: s type: ref possible_keys: idx_zone_ra key: idx_zone_ra key_len: 4 ref: serge.zz.matchZoneId rows: 30444 Extra: Using where EXPLAIN SELECT STRAIGHT_JOIN p.id, s.id FROM InMemoryDIASource AS p INNER JOIN ZoneZone AS zz FORCE INDEX (PRIMARY) ON p.zoneId = zz.zoneId INNER JOIN InMemoryObject AS s FORCE INDEX (idx_zone_ra) ON zz.matchZoneId = s.zoneId AND s.ra BETWEEN p.ra - zz.deltaRa AND p.ra + zz.deltaRa WHERE s.decl BETWEEN p.decl - 0.000833 AND p.decl + 0.000833 AND POW(p.x - s.x, 2) + POW(p.y - s.y, 2) + POW(p.z - s.z, 2) < 2.1137067679466e-10 \G *************************** 1. row *************************** id: 1 select_type: SIMPLE table: p type: ALL possible_keys: idx_zone_ra key: NULL key_len: NULL ref: NULL rows: 30276 Extra: *************************** 2. row *************************** id: 1 select_type: SIMPLE table: zz type: ref possible_keys: PRIMARY key: PRIMARY key_len: 4 ref: serge.p.zoneId rows: 323 Extra: *************************** 3. row *************************** id: 1 select_type: SIMPLE table: s type: ref possible_keys: idx_zone_ra key: idx_zone_ra key_len: 4 ref: serge.zz.matchZoneId rows: 30444 Extra: Using where 3 rows in set (0.00 sec)