Is there a way to get sync gateway last_seq without retrieving all docs?

I want to retrieve the sync gateway last_seq value without retrieving the list of ids and revs for all documents accessible to the user. I don’t see anything in the documentation for this, it only returns it as part of the _changes call and there is no option right now to just retrieve the current last_seq for the latest update. Calling _changes on all documents can take over a minute for me so I can’t use that to get the initial value, but I would really like to be able to use the _changes call to check for any new updates since I last checked.

I don’t think there’s currently a way to get the last_seq for a user outside of the standard _changes usage. Since Sync Gateway isn’t maintaining any state information for a given user, the value of last_seq is really just a function of the _changes requested (specifically the since value).

I’d like to better understand your particular usage scenario. Normally I’d expect _changes to address what you’re looking for - the set of changes that have been made since the last synchronization. You mention that your _changes call is having to retrieve all documents (as opposed to just the recent ones), so I assume you’re using it a bit differently? If you’re able to share a few more details of how you’re using the _changes feed, we might be able to identify potential options.

I’m using couchbase as the backend to a web portal and originally we used _all_docs to retrieve everything when a user logged in, then used _changes to check for any updates whenever we needed to refresh data (page change, etc.). That call has gotten way too slow in the latest version of sync gateway, and it isn’t sustainable for us since our users will be generating more and more documents over time. We already have users with over 20000 documents, so I can’t just retrieve all _changes to get the last_seq value, but I would like to use it to handle a quick check for changes. Right now I just re-run my initial view and update all data. If there was a way I could have the _changes call just return the most recently updated document and last_seq that would fit my scenario perfectly.

A few followup questions:

  1. Which call have you seen running slower in the latest sync gateway - _all_docs, or _changes?
  2. When you’re using _changes to check for updates when refreshing data, what are you using as the since value? You shouldn’t need to retrieve all 20000 documents each time, but maybe I’m misunderstanding the use case?


  1. “_all_docs” was the one running slower. I asked about that in a different post and someone said it was probably due to a change they made in that call that had to do with how it handled stale records.

  2. The since parameter is just the last_seq of a previous call, but if a user is logging in I have no idea what the last_seq should be to send in for since. It could be a brand new user with a couple dozen docs or an older user with thousands. What I’d like is some way to retrieve just the last_seq from a call to _changes so that I could send that in for the next call to see any changes made since they logged in. Multiple users have access to the same docs so if one user changes them while a second user is logged in I’d like to see those changes and reflect them on the site for the second user without having to pull everything in for a view and updating it all.