Is N1QL a good choose for activity feed use case (using IN clause and timestamp ordered)?

Hi i have a general question.

So when building your app you can either introduce another moving part (db) or create it in your primary db (Couchbase). Without having done any tests can you say something about how efficient
n1ql would handle an activity feed where a json field is the ”key” for retrieval and has been indexed, so the feed should be fan out on read. The documents should be sorted according to a timestamp, i guess there is no such thing in couchbase that store the index according to timestamp so it has to resort it for every request ?

Also this feed has to have some relevance to the user so it should contain post from who i am following, meaning i am looking at using the IN clause. If you have many followers (hundreds or maybe thousand) and perform the above mentioned operation. Is this a scalable solution ?

Or should i looking into other ordered sets data structures ?


Your documents can contain a timestamp field and you can index on that field in addition to the key.

As far as followers, you would model these as relationships (one document containing the key of the related document). You can use N1QL queries and joins to navigate these relationships. I don’t think the IN clause applies here.

Our indexes are conceptually a way to obtain ordered data structures. So what you are asking can be done. Couchbase, however, is a general-purpose document database, and not specialized to either time-series data or graph data.

Many thanks Gerald, I will give it a try. But am i right that the index created by N!QL is stored on disk, some kind of B-tree ?
As for using the IN clause i mean to say follow a certain topic like #databases more than friends that can be a json field in the document. I will try some tests with some data and report back my findings.

The indexes are tree-based. They are persistent but also cached, just like data in Couchbase.