I’m trying to grab some trend data by hours of day. I have a fact table that has a reference to a TimeDimension. The TimeDimension has one entry for every minute of the day, plus an entry for “unspecified” (1441 entries in all). The TimeDimension looks like this:
CREATE TABLE `TimeDimension` (
`timeID` int(11) NOT NULL,
`hour` tinyint(4) NOT NULL,
`minuteOfHour` tinyint(4) NOT NULL,
`minuteOfDay` smallint(6) NOT NULL,
`timestamp` time NOT NULL,
`halfDayOfDay` tinyint(4) NOT NULL,
`hourOfHalfDay` tinyint(4) NOT NULL,
`halfOfHour` tinyint(4) NOT NULL,
`quarterOfHour` tinyint(4) NOT NULL
) ENGINE=BRIGHTHOUSE DEFAULT CHARSET=latin1;
The fact table also has a column for organization, so I can constrain queries to organizations. I want to get the number of facts for each hour of the day for a particular organization, so I have a query:
SELECT t.hour, count(c.factID)
FROM TimeDimension t
LEFT JOIN Facts c
ON c.initiatedTime=t.timeID
AND c.org=1234
GROUP BY t.hour
ORDER BY t.hour;
This returns:
ERROR 5 (HY000): The query includes syntax that is not supported by the Infobright Optimizer. Either restructure the query with supported syntax, or enable the MySQL Query Path in the brighthouse.ini file to execute the query with reduced performance.
I have an identical structure implemented using MyISAM for performance comparisons and I get the following from that:
mysql> select t.hour, count(c.factID)
from TimeDimension t
LEFT JOIN Facts c on c.initiatedTime=t.timeID
and c.org=1234
group by t.hour
order by t.hour;
+———+—————————-+
| hour | count(c.factID) |
+———+—————————-+
| -1 | 0 |
| 0 | 2 |
| 1 | 0 |
| 2 | 2 |
| 3 | 0 |
| 4 | 0 |
| 5 | 0 |
| 6 | 0 |
| 7 | 0 |
| 8 | 1 |
| 9 | 0 |
| 10 | 1 |
| 11 | 7 |
| 12 | 3 |
| 13 | 6 |
| 14 | 2 |
| 15 | 10 |
| 16 | 25 |
| 17 | 8 |
| 18 | 3 |
| 19 | 1 |
| 20 | 2 |
| 21 | 1 |
| 22 | 3 |
| 23 | 0 |
+———+—————————-+
25 rows in set (0.00 sec)
If I move the c.org=1234 into the WHERE clause then I don’t get the hours of the day with a count() of 0, but the query works on both Brighthouse and MyISAM:
mysql> select t.hour, count(c.factID)
from TimeDimension t
LEFT JOIN Facts c on c.initiatedTime=t.timeID
where c.uoid=1234
group by t.hour
order by t.hour;
+———+—————————-+
| hour | count(c.FTCallID) |
+———+—————————-+
| 0 | 2 |
| 2 | 2 |
| 8 | 1 |
| 10 | 1 |
| 11 | 7 |
| 12 | 3 |
| 13 | 6 |
| 14 | 2 |
| 15 | 10 |
| 16 | 25 |
| 17 | 8 |
| 18 | 3 |
| 19 | 1 |
| 20 | 2 |
| 21 | 1 |
| 22 | 3 |
+———+—————————-+
16 rows in set (0.00 sec)
I need to return one row per hour for the graphs to work, otherwise I end up with missing values on the X-axis of the graph. Any ideas how to get this data from Brighthouse?

