Index not improve speed in couchbase 4.5

冷暖自知 提交于 2019-12-25 07:48:16

问题


I have below query

SELECT day,count(DISTINCT campaignId) campaigns
FROM Inheritx use index(daily_type_1)
where _type='DailyCampaignUsage'
group by day

I have below index

 `CREATE INDEX `daily_type_1` ON `Inheritx` 
(`_type`,`day`,(distinct (`campaignId`))) WHERE (`_type` = "DailyCampaignUsage")`

it is taking 3s and I habe 52k data whare _type= "DailyCampaignUsage"

how I Can improve it's speed ?


回答1:


Modify your index as follows.

CREATE INDEX `daily_type_1` ON `Inheritx` (campaignId,`day`)
WHERE (`_type` = "DailyCampaignUsage");

Keep the index in this answer. Modify your query as follows.

SELECT day,count(DISTINCT campaignId) campaigns
FROM Inheritx use index(daily_type_1)
where _type='DailyCampaignUsage'
and campaignId is not null
group by day;


来源:https://stackoverflow.com/questions/41544159/index-not-improve-speed-in-couchbase-4-5

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!