Performance and best practice on couchbase lite 2.5

Hi everybody,
I would like to open a discussion about what is the best practice to use the query on an android application and evaluate several aspect in term of performance.

In the example the query is built on the fly then executed it,

There is any impact on the performance creating the query every time, or is it better save it in a singleton object and reuse it every time? What if I have a to attach a listener to a query (old live query 1.4)?

In our mobile application we use to attach to every document a listener, this because the code is been migrating from couchbase lite 1.4 to 2.5 and we might have thousand of documents.
Now the new library does not allow to attach listener to the document itself, but on the database, to a particular document id [addDocumentChangeListener] but now there is also the listener to the whole database [addChangeListener]
What is the best practice to deal with this kind of issue? Having thousand of document which approach give the best performance?

Thanks for any feedback, I would like to have your opinion and if you had the same kind of issues in your projects.

-Paolo

Creating a query is relatively expensive so you’d get a benefit from saving queries around. If you need them to be a bit more flexible you can introduce query variables into the query statement.

The rest is unclear what you are actually trying to do. Why is it that you need to listen to every document?

Now the new library does not allow to attach listener to the document itself, but on the database, to a particular document id

It’s the same functionality, the API is just a little bit different.

Adding listeners to a lot of documents can get expensive. It’s better to add a database listener and then just look at the document ID in the notification.