Hi Piotr,

To first order, yes, I’d try to have every query an application issues be 
satisfied by an index.

If you’ve got some queries that you run infrequently in the background those 
may not warrant an index, as the resources required to keep the index 
up-to-date would be greater than the cost of just scanning the entire database.

Cheers, Adam

> On Jun 4, 2020, at 8:53 AM, Piotr Zarzycki <[email protected]> wrote:
> 
> Hello everyone,
> 
> We are building JS based application which storing data in CouchDb. It is a
> greenfield application in case of front end and database structure. I would
> use some examples at the beginning.
> 
> I have some selector which gets me data from db:
> 
> const q = {
>      selector: {
>        historyId: document.historyId,
>      },
>      sort: [{ version: "desc" }],
>      limit: 500,
>    };
> 
> 
> In the results I will get data along with warning:
> 
> "warning": "no matching index found, create an index to optimize query time"
> 
> 
> I can easily get rid of that warning by adding using Fauxton index:
> 
> {
>   "index": {
>      "fields": [
>         "historyId"
>      ]
>   },
>   "name": "historyId-json-index",
>   "type": "json"
> }
> 
> 
> My question is - How do you guys approach to working with indexes ? Should
> I add it to each query which I'm doing ?
> 
> Thoughts about approaches would be much appreciated. :)
> 
> Thanks,
> -- 
> 
> Piotr Zarzycki
> 
> Patreon: *https://www.patreon.com/piotrzarzycki
> <https://www.patreon.com/piotrzarzycki>*

Reply via email to