google-bigquery - Google-Bigquery:查询扫描整个表而不是分区表中的给定范围
问题描述
我有一个事实表,其中包含 5000 万条名为 AccountLines 的记录,由 Posting_Date_New 分区。当我过滤特定分区列上的记录时,我的查询工作正常并且只扫描给定范围之间的有限数据。但是当我在 Posting_Date_New 列的基础上加入 Dimension 表并在 Financial Year 上进行过滤时,它会扫描整个表。我怎么解决这个问题?我需要将我的事实表与维度表连接起来,并在不扫描整个表的情况下过滤维度表的列。请帮忙。
我的查询如下。
--查询完成(经过 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.51 GB)
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
解决方案
推荐阅读
- docker - 桌面客户端软件感知容器如何故障转移到另一个 Docker Swarm 工作节点?
- javascript - 如何清除 div 中的值(TICTACTOE GAME)
- c# - 如何让 Resharper 保留一些代码?
- python-3.x - 在python中使用正则表达式获取一组数字
- javascript - 如何在不使用缓存中的陈旧文件的情况下加载脚本 js?
- c# - WriteAllText 方法返回最后一行,而不是文件的整行
- asp.net - 将下拉列表中所选项目的名称打印到标签
- css - Firefox中的CSS变换旋转像素问题
- sql - 如何在 SQLite 中更新字段并将其设置为“b”?
- python - 反透视虚拟变量