レポート合計の集計ルールの割当て

このトピックは、レポート合計の集計ルールを明示的に割り当てる方法について説明しています。これは、パフォーマンスの向上に役立ち、特にOracle Analyticsでレポートを記述する技術開発者を対象としています。

次の図は、レポート定義が年、月、および顧客地域で、メトリックが重複を除いた顧客数(オーダーあり)として定義されるCount Distinct of Customers with Ordersである例を示しています。

GUID-4E9DB43C-F827-4BBB-A94D-5A91F3626C72-default.jpgの説明が続きます
.jpgの説明

論理問合せは次のようになります。

SELECT
   0 s_0,
   "A - Sample Sales"."Cust Regions"."C50  Region" s_1,
   "A - Sample Sales"."Counts"."32  # of Cust with Orders  (Cnt Distinct)" s_2,
   REPORT_AGGREGATE("A - Sample Sales"."Counts"."32  # of Cust with Orders  (Cnt Distinct)" BY ) s_3
FROM "A - Sample Sales"
WHERE
("Time"."T02 Per Name Month" = '2011 / 11')
ORDER BY 2 ASC NULLS LAST
FETCH FIRST 500001 ROWS ONLY

物理問合せは次のようになります。

WITH
SAWITH0 AS (select count(distinct T42433.Cust_Key) as c1,
     T42430.Region as c2
from
     BISAMPLE.SAMP_CUSTOMERS_D T42428 /* D60 Customers */ ,
     BISAMPLE.SAMP_ADDRESSES_D T42430 /* D62 Customers Addresses */ ,
     BISAMPLE.SAMP_TIME_MTH_D T42405 /* D02 Time Month Grain */ ,
     BISAMPLE.SAMP_REVENUE_F T42433 /* F10 Billed Rev */
where  ( T42405.Mth_Key = T42433.Bill_Mth_Key and T42405.Per_Name_Month = '2011 / 11' and T42428.Cust_Key = T42433.Cust_Key and T42428.Address_Key = T42430.Address_Key )
group by T42430.Region),
SAWITH1 AS (select count(distinct T42433.Cust_Key) as c1
from
     BISAMPLE.SAMP_TIME_MTH_D T42405 /* D02 Time Month Grain */ ,
     BISAMPLE.SAMP_REVENUE_F T42433 /* F10 Billed Rev */
where  ( T42405.Per_Name_Month = '2011 / 11' and T42405.Mth_Key = T42433.Bill_Mth_Key ) )
select D1.c1 as c1, D1.c2 as c2, D1.c3 as c3, D1.c4 as c4 from ( select D1.c1 as c1,
     D1.c2 as c2,
     D1.c3 as c3,
     D1.c4 as c4
from
     (select 0 as c1,
               D1.c2 as c2,
               D1.c1 as c3,
               D2.c1 as c4,
               ROW_NUMBER() OVER (PARTITION BY D1.c2 ORDER BY D1.c2 ASC) as c5
          from
               SAWITH0 D1,
               SAWITH1 D2
     ) D1
where  ( D1.c5 = 1 )
order by c2 ) D1 where rownum <= 500001

合計値の480は、構成値の182 + 113 + 185の合計です。合計を計算する論理問合せの式は、“REPORT_AGGREGATE("A - Sample Sales"."Counts"."32 # of Cust with Orders (Cnt Distinct)" BY ) s_3”となります。

REPORT_AGGREGATEが使用される場合、合計は構成値とは関係なく計算されます。ただし、このレポート設計では、このレポートの構成値から正しい合計を計算できます。

列式を編集して「集計ルール(合計行)」を「サーバー複合集計」から「合計」に変更した場合、論理および物理SQL問合せが変更されます。

次の図は、元の集計を示しています。

GUID-96FB697B-24F7-41A9-8678-F99921E5BB19-default.pngの説明が続きます
.pngの説明

次の図は、変更後の集計を示しています。

GUID-ED289D12-C0BD-4588-B288-2069EAB3EB1D-default.pngの説明が続きます
.pngの説明

変更後の論理SQL問合せにはREPORT_SUMがあります。

SELECT
   0 s_0,
   "A - Sample Sales"."Cust Regions"."C50  Region" s_1,"A - Sample Sales"."Counts"."32  # of Cust with Orders  (Cnt Distinct)" s_2,
   REPORT_SUM("A - Sample Sales"."Counts"."32  # of Cust with Orders  (Cnt Distinct)" BY ) s_3
FROM "A - Sample Sales"
WHERE
("Time"."T02 Per Name Month" = '2011 / 11')
ORDER BY 2 ASC NULLS LAST
FETCH FIRST 500001 ROWS ONLY

これは、生成される物理問合せです。

WITH
SAWITH0 AS (select count(distinct T42433.Cust_Key) as c1,
     T42430.Region as c2
from
     BISAMPLE.SAMP_CUSTOMERS_D T42428 /* D60 Customers */ ,
     BISAMPLE.SAMP_ADDRESSES_D T42430 /* D62 Customers Addresses */ ,
     BISAMPLE.SAMP_TIME_MTH_D T42405 /* D02 Time Month Grain */ ,
     BISAMPLE.SAMP_REVENUE_F T42433 /* F10 Billed Rev */
where  ( T42405.Mth_Key = T42433.Bill_Mth_Key and T42405.Per_Name_Month = '2011 / 11' and T42428.Cust_Key = T42433.Cust_Key and T42428.Address_Key = T42430.Address_Key )
group by T42430.Region),
SAWITH1 AS (select 0 as c1,
     D1.c2 as c2,
     D1.c1 as c3
from
     SAWITH0 D1)
select D1.c1 as c1, D1.c2 as c2, D1.c3 as c3, D1.c4 as c4 from ( select D1.c1 as c1,
     D1.c2 as c2,
     D1.c3 as c3,
     sum(D1.c3) over ()  as c4
from
     SAWITH1 D1
order by c2 ) D1 where rownum <= 500001

明示的に集計を設定する同じオプションをワークブックで使用できますビジュアライゼーションの数値の書式設定を参照してください。この例では、列「Count Distinct Customers with Orders」で、「集計方法」「合計」に変更します。

レポートをレビューして、最適な集計ルールがレポートで使用されていることを確認します。レポート設計で許可されている場合は、明示的な集計ルールを使用してください。

レポートの詳細は、分析の作成を参照してください