MariaDB [test]> alter table t1 drop primary key;
|
Query OK, 2 rows affected (0.046 sec)
|
Records: 2 Duplicates: 0 Warnings: 0
|
|
MariaDB [test]> alter table t2 drop primary key;
|
Query OK, 3 rows affected (0.022 sec)
|
Records: 3 Duplicates: 0 Warnings: 0
|
|
MariaDB [test]> desc SELECT t1a.*, t2a.*, t2i.K2 AS K2B, t2i.K1r AS K1rB, t2i.rowTimestamp AS rowTimestampB, t2i.Event AS EventB FROM t1 t1a JOIN t2 t2a ON t2a.K1r = t1a.K1 LEFT JOIN ( t1 t1i LEFT JOIN t2 t2i ON t2i.K1r = t1i.K1) ON (t1i.K1 = 1) AND (((t2i.K1r = t1a.K1 AND t2i.rowTimestamp > t2a.rowTimestamp ) OR (t2i.rowTimestamp = t2a.rowTimestamp AND t2i.K2 > t2a.K2)) OR (t2i.K2 IS NULL)) WHERE t2a.K1r = 1 AND t2i.K2 IS NULL;
|
+------+-------------+-------+------+---------------+------+---------+------+------+--------------------------------------------------------------------+
|
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
|
+------+-------------+-------+------+---------------+------+---------+------+------+--------------------------------------------------------------------+
|
| 1 | SIMPLE | t1a | ALL | NULL | NULL | NULL | NULL | 2 | Using where |
|
| 1 | SIMPLE | t2a | ALL | NULL | NULL | NULL | NULL | 3 | Using where; Using join buffer (flat, BNL join) |
|
| 1 | SIMPLE | t1i | ALL | NULL | NULL | NULL | NULL | 2 | Using where; Using join buffer (incremental, BNL join) |
|
| 1 | SIMPLE | t2i | ALL | NULL | NULL | NULL | NULL | 3 | Using where; Not exists; Using join buffer (incremental, BNL join) |
|
+------+-------------+-------+------+---------------+------+---------+------+------+--------------------------------------------------------------------+
|
4 rows in set (0.016 sec)
|
|
MariaDB [test]> SELECT t1a.*, t2a.*, t2i.K2 AS K2B, t2i.K1r AS K1rB, t2i.rowTimestamp AS rowTimestampB, t2i.Event AS EventB FROM t1 t1a JOIN t2 t2a ON t2a.K1r = t1a.K1 LEFT JOIN ( t1 t1i LEFT JOIN t2 t2i ON t2i.K1r = t1i.K1) ON (t1i.K1 = 1) AND (((t2i.K1r = t1a.K1 AND t2i.rowTimestamp > t2a.rowTimestamp ) OR (t2i.rowTimestamp = t2a.rowTimestamp AND t2i.K2 > t2a.K2)) OR (t2i.K2 IS NULL)) WHERE t2a.K1r = 1 AND t2i.K2 IS NULL;
|
+----+--------+----+------+---------------------+--------------+------+------+---------------+--------+
|
| K1 | Name | K2 | K1r | rowTimestamp | Event | K2B | K1rB | rowTimestampB | EventB |
|
+----+--------+----+------+---------------------+--------------+------+------+---------------+--------+
|
| 1 | T1Row1 | 1 | 1 | 2015-04-13 10:42:11 | T1Row1Event1 | NULL | NULL | NULL | NULL |
|
| 1 | T1Row1 | 2 | 1 | 2015-04-13 10:42:12 | T1Row1Event2 | NULL | NULL | NULL | NULL |
|
| 1 | T1Row1 | 3 | 1 | 2015-04-13 10:42:12 | T1Row1Event3 | NULL | NULL | NULL | NULL |
|
+----+--------+----+------+---------------------+--------------+------+------+---------------+--------+
|
3 rows in set (0.010 sec)
|
|
MariaDB [test]>
|