我有一个如下的查询
select sum(ARRAY_SUM(DailyCampaignUsage.`data`[*].cost)) revenue from
Inheritx DailyCampaignUsage WHERE DailyCampaignUsage._type='DailyCampaignUsage'
正在采取 12.3s
此处计数(ARRAY_SUM(DailyCampaignUsage。data
[*]。费用)) 51k
我如何才能提高它的性能? 我的索引如下
CREATE INDEX `abc` ON `Inheritx`(`_type`) USING GSI
答案 0 :(得分:1)
使用覆盖部分索引。
CREATE INDEX idx_covering ON Inheritx(_type, data[*].cost) WHERE _type = 'DailyCampaignUsage';
select sum(ARRAY_SUM(DailyCampaignUsage.`data`[*].cost)) revenue
from Inheritx DailyCampaignUsage USE INDEX ( idx_covering )
WHERE DailyCampaignUsage._type='DailyCampaignUsage'