Couch ignores use_index, and Pouch errors on use_index, and they both are choosing different indexes by default

Aperta
#8,980 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
30/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
javascript
Ambito
databases

Direzione di ricerca

Inizia confrontando il comportamento HTTP di _find e _explain in CouchDB 3.3.3 e PouchDB 8.0.1, concentrandoti sulla selezione predefinita dell'indice e sull'uso dell'opzione use_index. Riproduci i selettori e gli indici forniti, quindi determina il comportamento compatibile previsto e documenta o testa il risultato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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-node 8,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-index but
  • 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"
          ]
        }
      }
    }
  }
}
Lingua principale
JavaScript
Stelle
17.6k
Fork
1.5k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/pouchdb

Tutte le issue di apache/pouchdb

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.