Couch ignores use_index, and Pouch errors on use_index, and they both are choosing different indexes by default
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 30/100
- Issue 类型
- 缺陷
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- javascript
- 领域
- databases
调研方向
首先比较 CouchDB 3.3.3 和 PouchDB 8.0.1 中 _find 与 _explain 的 HTTP 行为,重点关注默认索引选择以及 use_index 选项的使用。重现所提供的选择器和索引,然后确定预期的兼容行为,并记录或测试结果。
由索引模型根据 Issue 内容生成。
描述
Issue
CouchDb and PouchDb choose different indexes for a _find query that does not specify any index.
Is any of this to be expected, or am I doing something wrong? Thanks in advance.
And when trying to force use_index, Couch ignores it and Pouch errors. Seems like ignoring is the better route?
Info
- For pouch, using
pouchdb-node8,0.1 - Platform: Chrome
- Server: Both CouchDB 3.3.3 and PouchDB 8.0.1
Reproduce
Use the above server versions and a TypeScript client that uses http _find calls as described below:
I have a note document type, that looks like this:
{
"_id": "note:609ed703-ee69-46ec-8be2-4c70d25ad44e",
"_rev": "9-e1f3a3d98d32cbe361bf4ec0665071f9",
"type": "note",
"journal_id": "djrn:c669a908-b345-4ee4-9095-84babc8aea66",
"title": "2024-08-25 note",
"body": "Some text stuff\n",
"created_at": "2024-08-25",
"updated_at": "2024-08-26",
"tags": []
}
And when I do a _find (by tag matches), using this:
{
"selector": {
"type": {
"$in": [
"note"
]
},
"tags": {
"$in": [
"asdfasdfasdf",
"ddddddddd"
]
}
},
"fields": [
"_id",
"title",
"tags",
"updated_at"
],
}
It works fine, but when I use _explain I see that Couch and Pouch are using different indexes:
- CouchDb is using
type-indexbut - PouchDb is using
tags-index.
(I tried adding use_index, but it seems CouchDb ignores this, and PouchDb errors out (~"could not find the index, or could not use it for this query").
Here is an example of what the indexes look like; they are almost identical in Couch and Pouch:
type-index from PouchDb (same index is in Couch, except for id, rev):
{
"_id": "_design/idx-bae76d56ce6ab639848d59c2a1d8b364",
"language": "query",
"views": {
"type-index": {
"map": {
"fields": {
"type": "asc"
}
},
"reduce": "_count",
"options": {
"def": {
"fields": [
"type"
]
}
}
}
},
"_rev": "1-dd74d6c53ea6e913934d836695512a07"
}
tags-index from CouchDb (same index is in Pouch, except for id, rev):
{
"_id": "_design/723268ced4323d1b517d25ade1287381c0147cef",
"_rev": "1-cc3ee54469dd17f10c535366c2e1f972",
"language": "query",
"views": {
"tags-index": {
"map": {
"fields": {
"tags": "asc"
},
"partial_filter_selector": {}
},
"reduce": "_count",
"options": {
"def": {
"fields": [
"tags"
]
}
}
}
}
}
- 主要语言
- JavaScript
- 星标
- 17.6k
- 派生
- 1.5k
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
apache/pouchdb 的其他 Issue
-
elemMatch throws TypeError: value is null if array has null element可能已有人在做 @henyanagar 于 144 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 4/5 3-5 天 新手友好度 22/100
-
难度 3/5 1-2 天 新手友好度 55/100
-
难度 3/5 1-2 天 新手友好度 65/100
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 73/100
hugomrdias/playwright-test#753 ·
维护者通常 1 天内回复
-
bug good first issue
难度 2/5 1-3 小时 新手友好度 86/100
KonstantinStarovoytov/kitden#21 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 67/100
-
难度 2/5 1-3 小时 新手友好度 70/100
guybedford/es-module-shims#556 ·
-
app ernst:4-klein
难度 2/5 1-3 小时 新手友好度 75/100
NewspeedyNL/PidLane#683 ·
维护者通常 1 天内回复