我正在开发一个系统来使用 couchbase 存储我们的翻译。
我的存储桶中有大约 15,000 个条目,如下所示:
{
"classifications": [
{
"documentPath": "Test Vendor/Test Project/Ordered",
"position": 1
}
],
"id": "message-Test Vendor/Test Project:first",
"key": "first",
"projectId": "project-Test Vendor/Test Project",
"translations": {
"en-US": [
{
"default": {
"owner": "414d6352-c26b-493e-835e-3f0cf37f1f3c",
"text": "first"
}
}
]
},
"type": "message",
"vendorId": "vendor-Test Vendor"
},
例如,我想找到所有使用“Test Vendor/Test Project/Ordered”的“documentPath”分类的消息。
我使用这个查询:
SELECT message.*
FROM couchlate message UNNEST message.classifications classification
WHERE classification.documentPath = "Test Vendor/Test Project/Ordered"
AND message.type="message"
ORDER BY classification.position
但我很惊讶查询需要 2 秒才能执行!
查看查询执行计划,couchbase 似乎正在循环所有消息,然后在“documentPath”上进行过滤。
我希望它首先过滤“documentPath”(因为实际上只有 2 个 documentPaths 匹配我的查询)然后找到消息。
我试图在“分类”上创建一个索引,但它没有改变任何东西。
我的索引设置是否有问题,或者我应该以不同的方式构建数据以获得快速结果?
如果这很重要,我正在使用 couchbase 4.5 beta。