Hi Garren,

I am querying a CouchDB 2.0 backend, using pouchdb-find in
pure "remote" mode, without any synchronization.

Thanks for the blog post, that helps :) . So, effectively, the
"_id": {"$gt":0} selector is by no means a way to use an index
(that's the impression I got when I was suggested to try it).

It's only a way to suppress pouchdb-find's warning, by telling it
"I know this won't fit a map/reduce, I'll be running in-memory
operations on allDocs, and I'm aware of the perf. consequences".

Correct?

Final clarification: querying with or without the _id selector
produces the exact same operations with the same perf and the only
difference is the warning when we weren't explicit enough, right?

Thanks for the work on pouchdb-find! Good day.


On 2017-01-21 08:12, Garren Smith wrote:
Hi Ronan,

When using pouchdb-find are you querying a CouchDB backend or using
PouchDB?

The reason that adding "_id": {"$gt": 0} works is because
pouchdb-find/mango fetches all the docs using the _all_docs index
and then processes the $in operator in memory.

We have added functionality that the $in operator should work without
needing the "_id": {"$gt": 0} selector. So if it didn't work that
means there is a bug in pouchdb-find. I have written a blogpost on
how pouchdb-find/mango actually works and it might help you
understand what is actually happening [1].

Cheers

Garren

[1]
http://www.redcometlabs.com/blog/2015/12/1/a-look-under-the-covers-of-pouchdb-find


On Fri, Jan 20, 2017 at 11:21 PM, Ronan Jouchet wrote:

Hi, this is a mailing-list repost of StackOverflow question
"pouchdb-find: can $in / $or queries use indexes?" [1]

I noticed that queries using $in, such as:

    "type": {"$in": ["a", "b"]}

... fail to use the existing relevant index (pouchdb-find warns
"no matching index found, create an index to optimize query time").
StackOverflow user markwatsonatx suggested adding to my query

    "_id": {"$gt": 0}

... and indeed I no longer get index warnings with it.

Is this expected behavior? Can anyone explain what's going on?
Thanks!

[1] http://stackoverflow.com/questions/40686383/pouchdb-find-
can-in-or-queries-use-indexes


Reply via email to