我有一个事实数据表,其中包含5000万条由Posting_Date_New分区的名为AccountLines的记录。当我过滤特定分区列上的记录时,我的查询可以正常工作,并且只扫描给定范围内的有限数据。但当我在Posting_Date_New列的基础上与维度表进行连接,并根据财务年度进行过滤时,它会扫描整个表。我该如何解决这个问题?我需要将我的事实表与维度表连接起来,并在维度表的列上进行过滤,而无需扫描整个表。请帮帮忙。
我的问题如下。
--查询完成(已过5.542秒,已处理244.37 MB )
select ah.ChargeGroup, sum(Amount) Amount from SSIS_STAGING.AccountLine acc
inner join SSIS_STAGING.Dim_Times_BI_Clustering dd on dd.Posting_Date_New = acc.Posting_Date_New
inner join SSIS_STAGING.BranchHierarchy br on br.CostCenterId = acc.BookingBranchID
inner join SSIS_STAGING.Accounts_Hierarchy ah on ah.Account = acc.G_L
where acc.Posting_Date_New between '2018-04-01' and '2019-03-31' and ZoneName = 'BU-North'
group by ah.ChargeGroup--查询完成(16.530秒,已处理5.51G)
select ah.ChargeGroup, sum(Amount) Amount from SSIS_STAGING.AccountLine acc
inner join SSIS_STAGING.Dim_Times_BI_Clustering dd on dd.Posting_Date_New = acc.Posting_Date_New
inner join SSIS_STAGING.BranchHierarchy br on br.CostCenterId = acc.BookingBranchID
inner join SSIS_STAGING.Accounts_Hierarchy ah on ah.Account = acc.G_L
where dd.FinancialYear = '2018-19' and ZoneName = 'BU-North'
group by ah.ChargeGroup发布于 2018-09-01 02:57:45
要使用prune partitioned table,您需要在where子句中使用时间戳:
standardSQL
从table1 t1 INNER JOIN table2 t2 ON t1.id_field = t2 field2 WHERE t1.ts = CURRENT_TIMESTAMP()中选择t1.name,t2.category
https://stackoverflow.com/questions/52097079
复制相似问题