我有一个数据库结构,如:
{_id: 'record/1', name: 'Record 1', labels: ['label/1', 'label/2', 'label/3'], created: '2015-03-01T00:00:00.000Z'},
{_id: 'record/2', name: 'Record 2', labels: ['label/1', 'label/5', 'label/7', 'label/3'], created: '2015-03-06T00:00:00.000Z'},
{_id: 'record/3', name: 'Record 3', labels: ['label/2', 'label/3', 'label/4', 'label/5'], created: '2015-03-10T00:00:00.000Z'}
我有一个地图功能,每个文档发出多个密钥,即对于' record / 1',这些密钥将被发出:
[2015,3,1] for record/1
["label/1"] for record/1
["label/1",[2015,3,1]] for record/1
["label/1","label/3"] for record/1
["label/1","label/3",[2015,3,1]] for record/1
["label/1","label/2"] for record/1
["label/1","label/2",[2015,3,1]] for record/1
["label/1","label/2","label/3"] for record/1
["label/1","label/2","label/3",[2015,3,1]] for record/1
["label/2"] for record/1
["label/2",[2015,3,1]] for record/1
["label/2","label/3"] for record/1
["label/2","label/3",[2015,3,1]] for record/1
["label/3"] for record/1
["label/3",[2015,3,1]] for record/1
看起来每个文档要发出很多复杂的密钥,但它支持我的查询要求:
{startkey: [2015, 3, 1], endkey: [2015, 3, 9]}
{key: ['label/1', 'label/3']}
{startkey: ['label/1', 'label/3', [2015, 3, 1]], endkey: ['label/1', 'label/3', [2015, 3, 9]]}
问题:使用这种方法,我是否会遇到CouchDB或PouchDB中的任何限制或性能问题?
答案 0 :(得分:2)
不,这看起来可能是在PouchDB中使用map / reduce索引的最有效方法。 :)将所有内容放在一个大索引中肯定会在视图构建过程中获得最佳性能。