Hello!

We're using Pentaho BI 7.0.0.0.25

There is rather standard date dimension in our cube and month hierarchy in it:

<Hierarchy name="month_name" visible="true" hasAll="true" primaryKey="date" caption="..." description="...">
<Table name="tbl_date" schema="ta">
</Table>
<Level name="month_name" visible="true" column="month_name" ordinalColumn="month_num" type="String" uniqueMembers="false" levelType="TimeMonths" hideMemberIf="Never" caption="..." description="...">
</Level>
</Hierarchy>

As you can see, there is an ordinal column (month number).

Also we have an aggregation, which includes both month_name and month_num columns:

<Table name="qry_request" schema="ta">
<AggName name="qry_request_day" ignorecase="true">
<AggFactCount column="fact_count">
</AggFactCount>
...
<AggLevel column="month_num" name="[request_date.month_num].[month_num]" collapsed="true">
</AggLevel>
<AggLevel column="month_name" name="[request_date.month_name].[month_name]" collapsed="true">
</AggLevel>
...
</AggName>
</Table>





But, unfortunately mondrian is not using month_num field from an aggregation. Instead, it joins tbl_date table and uses month_num from there, which leads to performance degradation...

Here is the query:

select
"qry_request_day"."month_name" as "c0",
"tbl_date"."month_num" as "c1",
"qry_request_day"."calendar_year" as "c2"
from "ta"."qry_request_day" as "qry_request_day",
"ta"."tbl_date" as "tbl_date"
where
"tbl_date"."month_name" = "qry_request_day"."month_name"
and ("qry_request_day"."calendar_year" = 2017)
group by "qry_request_day"."month_name", "tbl_date"."month_num", "qry_request_day"."calendar_year"
order by "tbl_date"."month_num" ASC NULLS LAST, "qry_request_day"."calendar_year" ASC NULLS LAST

I googled it and found out, that there was jira task http://jira.pentaho.com/browse/MONDRIAN-1495 describing exactly the same behaviour.
But it was marked as fixed back in 6.0.0..

I wonder, was it really fixed? Or maybe I'm just doing something wrong?

Any help will be greatly appreciated.