mysql> EXPLAIN (SELECT `join_1_0`.`col39`, `join_1_0`.`col39`, `join_1_0`.`col39`, `join_1_0`.`col39`, `join_0_0`.`col22`, `join_0_0`.`col22`, `join_0_0`.`col22`, `join_0_0`.`col22` FROM `table76` AS `join_0_0`, `table335` AS `join_1_0` WHERE `join_0_0`.`col22`=`join_1_0`.`col39` OR `join_0_0`.`col29`='?' AND `join_1_0`.`col113`='?' GROUP BY `join_1_0`.`col39`,`join_0_0`.`col22` ORDER BY NULL ) UNION (SELECT `join_0_1`.`col1`, `join_1_1`.`col38`, `join_1_1`.`col38`, `join_1_1`.`col38`, `join_0_1`.`col1`, `join_1_1`.`col38`, `join_0_1`.`col1`, `join_0_1`.`col1` FROM `table267` AS `join_0_1`, `table229` AS `join_1_1` WHERE `join_0_1`.`col1`=`join_1_1`.`col38` OR `join_0_1`.`col1`='?' OR `join_1_1`.`col32`='?' GROUP BY `join_1_1`.`col38`,`join_1_1`.`col38`,`join_1_1`.`col38`,`join_1_1`.`col38`,`join_1_1`.`col38`,`join_0_1`.`col1`,`join_1_1`.`col38`,`join_0_1`.`col1`,`join_0_1`.`col1` ORDER BY `join_1_1`.`col38` ASC,`join_0_1`.`col1` ASC,`join_1_1`.`col38` ASC,`join_0_1`.`col1` DESC,`join_1_1`.`col38` ASC,`join_1_1`.`col38` ASC) UNION (SELECT `join_0_2`.`col24`, `join_1_2`.`col23`, `join_1_2`.`col23`, `join_0_2`.`col24`, `join_0_2`.`col24`, `join_0_2`.`col24`, `join_0_2`.`col24`, `join_0_2`.`col24` FROM `table76` AS `join_0_2`, `table859` AS `join_1_2` WHERE `join_0_2`.`col24`=`join_1_2`.`col23` XOR `join_0_2`.`col20`='?' AND `join_1_2`.`col0`='?' GROUP BY `join_1_2`.`col23`,`join_1_2`.`col23`,`join_1_2`.`col23` ORDER BY `join_1_ 2`.`col23` ASC) \G *************************** 1. row *************************** id: 1 select_type: PRIMARY table: join_1_0 type: ALL possible_keys: idx1,idx2 key: NULL key_len: NULL ref: NULL rows: 22 Extra: Using temporary; Using filesort *************************** 2. row *************************** id: 1 select_type: PRIMARY table: join_0_0 type: ALL possible_keys: idx1,idx7,idx10,idx35,idx39 key: NULL key_len: NULL ref: NULL rows: 33 Extra: Range checked for each record (index map: 0x8800000482) *************************** 3. row *************************** id: 2 select_type: UNION table: join_0_1 type: index possible_keys: idx0,idx2,idx4,idx6,idx8,idx10,idx11,idx12 key: idx8 key_len: 3 ref: NULL rows: 10 Extra: Using index; Using temporary; Using filesort; Using join cache *************************** 4. row *************************** id: 2 select_type: UNION table: join_1_1 type: ALL possible_keys: idx1,idx3 key: NULL key_len: NULL ref: NULL rows: 25 Extra: Using where *************************** 5. row *************************** id: 3 select_type: UNION table: join_0_2 type: ALL possible_keys: NULL key: NULL key_len: NULL ref: NULL rows: 33 Extra: Using temporary; Using filesort; Using join cache *************************** 6. row *************************** id: 3 select_type: UNION table: join_1_2 type: ALL possible_keys: NULL key: NULL key_len: NULL ref: NULL rows: 37 Extra: Using where *************************** 7. row *************************** id: NULL select_type: UNION RESULT table: type: ALL possible_keys: NULL key: NULL key_len: NULL ref: NULL rows: NULL Extra: 7 rows in set, 2 warnings (1.67 sec) mysql> show warnings; +---------+------+-----------------------------------------------------------+ | Level | Code | Message | +---------+------+-----------------------------------------------------------+ | Warning | 1292 | Incorrect datetime value: '?' for column 'col32' at row 1 | | Warning | 1292 | Incorrect datetime value: '?' for column 'col32' at row 1 | +---------+------+-----------------------------------------------------------+ 2 rows in set (0.02 sec)