All pastes #551738 Raw Edit

Untitled

public text v1 · immutable
·published 2007-06-08 22:40 UTC
rendered paste body
explain SELECT usageOtherTime as Date, "0" as Status 
FROM KSUsage WHERE usageEvent = 16 AND usageOtherTime BETWEEN '2007-06-07 00:00:00' AND '2007-06-07 10:00:00' 
UNION SELECT usageWhen as Date, "1" as Status 
FROM KSUsage WHERE usageEvent = 16 AND usageOtherTime BETWEEN '2007-06-07 00:00:00' AND '2007-06-07 10:00:00'
ORDER BY Date;

+----+--------------+------------+-------+------------------+------------------+---------+------+------+----------------+
| id | select_type  | table      | type  | possible_keys    | key              | key_len | ref  | rows | Extra          |
+----+--------------+------------+-------+------------------+------------------+---------+------+------+----------------+
|  1 | PRIMARY      | KSUsage    | range | usage_other_time | usage_other_time |       9 | NULL |  248 | Using where    |
|  2 | UNION        | KSUsage    | range | usage_other_time | usage_other_time |       9 | NULL |  248 | Using where    |
|NULL | UNION RESULT | <union1,2> | ALL   | NULL             | NULL             |    NULL | NULL | NULL | Using filesort |
+----+--------------+------------+-------+------------------+------------------+---------+------+------+----------------+

explain SELECT usageOtherTime as Date, "0" as Status
FROM KSUsage WHERE usageEvent = 16 AND usageOtherTime BETWEEN '2006-06-07 00:00:00' AND '2007-06-07 10:00:00'
UNION SELECT usageWhen as Date, "1" as Status
FROM KSUsage WHERE usageEvent = 16 AND usageOtherTime BETWEEN '2006-06-07 00:00:00' AND '2007-06-07 10:00:00'
ORDER BY Date;

+----+--------------+------------+------+------------------+------+---------+------+---------+----------------+
| id | select_type  | table      | type | possible_keys    | key  | key_len | ref  | rows    | Extra          |
+----+--------------+------------+------+------------------+------+---------+------+---------+----------------+
|  1 | PRIMARY      | KSUsage    | ALL  | usage_other_time | NULL |    NULL | NULL | 1491621 | Using where    |
|  2 | UNION        | KSUsage    | ALL  | usage_other_time | NULL |    NULL | NULL | 1491621 | Using where    |
|NULL | UNION RESULT | <union1,2> | ALL  | NULL             | NULL |    NULL | NULL |    NULL | Using filesort |
+----+--------------+------------+------+------------------+------+---------+------+---------+----------------+

-------But See, the data goes back to 2004---------

mysql> select * from KSUsage Limit 1;
+--------------------------+---------------------+-----------+---------------+-----------------+----------------+----------------+--------------------+----------------+-------------+----------------+------------+------------+-------------+-----------+---------------------+
| usageID                  | usageWhen           | usageEnum | usageServerID | usageServerType | usageProgramID | usageLicenseID | usageComputerID    | usageExpansion | usageUser   | usageAddress   | usageGroup | usageEvent | usageReason | usageTime | usageOtherTime      |
+--------------------------+---------------------+-----------+---------------+-----------------+----------------+----------------+--------------------+----------------+-------------+----------------+------------+------------+-------------+-----------+---------------------+
| 4123701500000020002C7233 | 2004-08-18 11:04:53 |        32 |       2912819 |               0 | 362E302E302E38 | NULL           | N00:0A:95:95:B2:44 | NULL           | USERNAME | 137.143.99.238 | NULL       |         16 |         115 |    166433 | 2004-08-16 12:51:00 |
+--------------------------+---------------------+-----------+---------------+-----------------+----------------+----------------+--------------------+----------------+-------------+----------------+------------+------------+-------------+-----------+---------------------+
1 row in set (0.00 sec)