維度-退化維度

剛接觸Mondrian,不熟悉若是隻有一個事實表,沒有單獨的維度表,其中事實表就包含維度信息的怎麼作Schema文件。一開始作了不少自關聯,致使性能降低明顯。基本多維度查詢速度就很慢,基本出不來了。ide

其實這種同在事實表的,能夠用退化維度來實現便可。性能

 

退化維度是這樣的一種維度:因爲它過於簡單而不值得爲它建立一個維表。考慮下面的事實表:

假設咱們爲支付方式列的值建立一個維表:spa

支付方式
Credit
Cash
ATMcode

這個維表沒什麼意義,它只有三個取值,沒有額外的信息,併產生了額外的鏈接開銷。你能夠建立一個退化維度,只要聲明一個維度卻不指定表,Mondrian 會認爲這些列是來自事實表。blog

 

<Cube name="Checkout">
    <Table name="checkout">
    <Dimension name="Payment method">
        <Hierarchy hasAll="true">
        <!-- 這裏沒有Table 元素 -->
            <Level name="Payment method" column="payment_method" uniqueMembers="true"/>
        </Hierarchy>
    </Dimension>
<!-- 其餘維度和度量-->
</Cube>    

注意:ip

因爲沒有鏈接,Dimension 的foreignKey 屬性是沒必要要的,而且Hierarchy 元素沒有Table 子元素或primaryKey 屬性。it

 

 

 上傳Saiku後分析速度也塊了。io

 

Schema文件class

<Schema name="FinSchema" description="&#36130;&#21153;&#27169;&#24335;" measuresCaption="&#36130;&#21153;&#27169;&#24335;">
    <Cube name="BalanceCube" caption="&#36164;&#20135;&#36127;&#20538;Cube" visible="true" description="&#36164;&#20135;&#36127;&#20538;Cube" cache="true" enabled="true">
        <Table name="&#36164;&#20135;&#36127;&#20538;&#35270;&#22270;" schema="dbo">
        </Table>
        <Dimension type="StandardDimension" visible="true" highCardinality="false" name="&#32452;&#32455;" caption="&#32452;&#32455;&#32534;&#30721;">
            <Hierarchy visible="true" hasAll="true" allMemberName="&#25152;&#26377;&#32452;&#32455;" allMemberCaption="&#25152;&#26377;&#32452;&#32455;">
                <Level name="&#32452;&#32455;&#32534;&#30721;" visible="true" column="&#32452;&#32455;&#32534;&#30721;" nameColumn="&#32452;&#32455;&#21517;&#31216;" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never">
                </Level>
                <Level name="&#32452;&#32455;&#21517;&#31216;" visible="true" column="&#32452;&#32455;&#21517;&#31216;" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never">
                </Level>
            </Hierarchy>
        </Dimension>
        <Dimension type="StandardDimension" visible="true" highCardinality="false" name="&#24180;">
            <Hierarchy name="YearHierarchy" visible="true" hasAll="true" allMemberName="&#25152;&#26377;&#24180;" allMemberCaption="&#25152;&#26377;&#24180;">
                <Level name="&#24180;" visible="true" column="&#24180;" type="Integer" uniqueMembers="false" levelType="Regular" hideMemberIf="Never">
                </Level>
                <Level name="&#26399;&#38388;" visible="true" column="&#26399;&#38388;" type="Integer" uniqueMembers="false" levelType="Regular" hideMemberIf="Never">
                </Level>
            </Hierarchy>
        </Dimension>
        <Dimension type="StandardDimension" visible="true" highCardinality="false" name="&#36134;&#31807;">
            <Hierarchy name="BookHierarchy" visible="true" hasAll="true" allMemberName="&#25152;&#26377;&#36134;&#31807;" allMemberCaption="&#25152;&#26377;&#36134;&#31807;">
                <Level name="&#36134;&#31807;&#21517;&#31216;" visible="true" column="&#36134;&#31807;&#21517;&#31216;" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never">
                </Level>
            </Hierarchy>
        </Dimension>
        <Dimension type="StandardDimension" visible="true" highCardinality="false" name="&#39033;&#30446;&#20998;&#31867;">
            <Hierarchy name="ItemTypeHierarchy" visible="true" hasAll="true" allMemberName="&#25152;&#26377;&#20998;&#31867;" allMemberCaption="&#25152;&#26377;&#20998;&#31867;">
                <Level name="&#39033;&#30446;&#20998;&#31867;" visible="true" column="&#39033;&#30446;&#20998;&#31867;" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never">
                </Level>
            </Hierarchy>
        </Dimension>
        <Dimension type="StandardDimension" visible="true" highCardinality="false" name="&#39033;&#30446;&#21517;&#31216;">
            <Hierarchy name="ItemHierarchy" visible="true" hasAll="true" allMemberName="&#25152;&#26377;&#39033;&#30446;" allMemberCaption="&#25152;&#26377;&#39033;&#30446;">
                <Level name="&#39033;&#30446;&#21517;&#31216;" visible="true" column="&#39033;&#30446;&#21517;&#31216;" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never">
                </Level>
            </Hierarchy>
        </Dimension>
        <Measure name="&#24180;&#21021;&#25968;" column="&#24180;&#21021;&#25968;" aggregator="sum" visible="true">
        </Measure>
        <Measure name="&#26399;&#26411;&#25968;" column="&#26399;&#26411;&#25968;" aggregator="sum" visible="true">
        </Measure>
    </Cube>
</Schema>
相關文章
相關標籤/搜索