You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by kowsik <ko...@gmail.com> on 2010/10/25 04:10:37 UTC
Questions about changes feed
I have a few questions about the _changes feed.
1. How many changes are kept around for each DB? Obviously, not
everything, but is it the last 100, 1000 or some other configurable
limit?
2. When I'm using a filter in a _design document, is the most recent
version of the _design document used for the filtering or does it
depend on the update seq? Let me elaborate:
seq #1 (added _design doc with filter v1)
seq #2 (doc A changed)
seq #3 (updated _design doc to v2)
seq #4 (doc B changed)
In the above case, when I invoke the _changes API, does it always use
the v2 filter for all changes or uses v1 for seq #2 and v2 for seq #4?
3. If there were a 1000 changes and I invoke _changes without 'since',
does all filter get invoked with all of the pending changes?
Thanks,
K
---
http://www.pcapr.net
http://twitter.com/pcapr
http://labs.mudynamics.com
Re: Questions about changes feed
Posted by Benjamin Young <be...@couchone.com>.
Marco, be careful about adding anything to a doc with an "_" in it as that's
a reserved "namespace" for CouchDB's own use.
That said, creating your own "trash" system on top of CouchDB (for
interested party notification, etc), is not a bad pattern. However,
depending on the existence of deleted docs for later filtering isn't great
as compaction would kill those off completely.
"_deleted: Indicates that this document has been deleted and will be removed
on next compaction run"
So they may not be there long enough to matter. You could avoid compaction,
but that's the road to an un-relaxing future. :) Better to implement a
compaction safe model on top of CouchDB, IMO.
Later,
Benjamin
On Tue, Nov 2, 2010 at 2:45 PM, Marco Monteiro <ma...@textovirtual.com>wrote:
> When you want to delete the document, save it with the additional property
> "_deleted" with the value true.
> This deletes the document but keeps the properties that the document has,
> which can then be used in the filter.
>
> Marco
>
> On 26 October 2010 04:38, kowsik <ko...@gmail.com> wrote:
>
> > On Mon, Oct 25, 2010 at 7:57 AM, Adam Kocoloski <ko...@apache.org>
> > wrote:
> > > On Oct 24, 2010, at 10:10 PM, kowsik wrote:
> > >
> > >> I have a few questions about the _changes feed.
> > >>
> > >> 1. How many changes are kept around for each DB? Obviously, not
> > >> everything, but is it the last 100, 1000 or some other configurable
> > >> limit?
> > >
> > > The most recent edit of each branch of every document is kept around
> > forever, or until a new edit on that branch occurs.
> >
> > Thanks Adam. A follow up observation (enhancement request really): I
> > like the way the filter code gets the document so it can use the
> > req.query to only push certain notification to certain clients.
> > Unfortunately when a document gets deleted all I get is something like
> > this:
> >
> >
> >
> {"seq":389,"id":"8f8bb53dbf8eb9be81923fea21072386","changes":[{"rev":"2-30b513fc78ad7eadd4db4b7f87591338"}],"deleted":true}
> >
> > It would be nice to have the actual doc be part of this so that the
> > filter can be more intelligent in its routing decision. For example,
> > only notify certain interested clients about the deletion.
> >
> > Thanks,
> >
> > K.
> > ---
> > http://www.pcapr.net
> > http://twitter.com/pcapr
> > http://labs.mudynamics.com
> >
>
Re: Questions about changes feed
Posted by Marco Monteiro <ma...@textovirtual.com>.
When you want to delete the document, save it with the additional property
"_deleted" with the value true.
This deletes the document but keeps the properties that the document has,
which can then be used in the filter.
Marco
On 26 October 2010 04:38, kowsik <ko...@gmail.com> wrote:
> On Mon, Oct 25, 2010 at 7:57 AM, Adam Kocoloski <ko...@apache.org>
> wrote:
> > On Oct 24, 2010, at 10:10 PM, kowsik wrote:
> >
> >> I have a few questions about the _changes feed.
> >>
> >> 1. How many changes are kept around for each DB? Obviously, not
> >> everything, but is it the last 100, 1000 or some other configurable
> >> limit?
> >
> > The most recent edit of each branch of every document is kept around
> forever, or until a new edit on that branch occurs.
>
> Thanks Adam. A follow up observation (enhancement request really): I
> like the way the filter code gets the document so it can use the
> req.query to only push certain notification to certain clients.
> Unfortunately when a document gets deleted all I get is something like
> this:
>
>
> {"seq":389,"id":"8f8bb53dbf8eb9be81923fea21072386","changes":[{"rev":"2-30b513fc78ad7eadd4db4b7f87591338"}],"deleted":true}
>
> It would be nice to have the actual doc be part of this so that the
> filter can be more intelligent in its routing decision. For example,
> only notify certain interested clients about the deletion.
>
> Thanks,
>
> K.
> ---
> http://www.pcapr.net
> http://twitter.com/pcapr
> http://labs.mudynamics.com
>
Re: Questions about changes feed
Posted by kowsik <ko...@gmail.com>.
On Mon, Oct 25, 2010 at 7:57 AM, Adam Kocoloski <ko...@apache.org> wrote:
> On Oct 24, 2010, at 10:10 PM, kowsik wrote:
>
>> I have a few questions about the _changes feed.
>>
>> 1. How many changes are kept around for each DB? Obviously, not
>> everything, but is it the last 100, 1000 or some other configurable
>> limit?
>
> The most recent edit of each branch of every document is kept around forever, or until a new edit on that branch occurs.
Thanks Adam. A follow up observation (enhancement request really): I
like the way the filter code gets the document so it can use the
req.query to only push certain notification to certain clients.
Unfortunately when a document gets deleted all I get is something like
this:
{"seq":389,"id":"8f8bb53dbf8eb9be81923fea21072386","changes":[{"rev":"2-30b513fc78ad7eadd4db4b7f87591338"}],"deleted":true}
It would be nice to have the actual doc be part of this so that the
filter can be more intelligent in its routing decision. For example,
only notify certain interested clients about the deletion.
Thanks,
K.
---
http://www.pcapr.net
http://twitter.com/pcapr
http://labs.mudynamics.com
Re: Questions about changes feed
Posted by Adam Kocoloski <ko...@apache.org>.
On Oct 24, 2010, at 10:10 PM, kowsik wrote:
> I have a few questions about the _changes feed.
>
> 1. How many changes are kept around for each DB? Obviously, not
> everything, but is it the last 100, 1000 or some other configurable
> limit?
The most recent edit of each branch of every document is kept around forever, or until a new edit on that branch occurs.
> 2. When I'm using a filter in a _design document, is the most recent
> version of the _design document used for the filtering or does it
> depend on the update seq? Let me elaborate:
>
> seq #1 (added _design doc with filter v1)
> seq #2 (doc A changed)
> seq #3 (updated _design doc to v2)
> seq #4 (doc B changed)
>
> In the above case, when I invoke the _changes API, does it always use
> the v2 filter for all changes or uses v1 for seq #2 and v2 for seq #4?
If you submit the _changes request after #3 has been saved you'll use v2 of the filter for all changes. I believe if you submit the request before #3 is saved your entire request will be filtered using v1.
> 3. If there were a 1000 changes and I invoke _changes without 'since',
> does all filter get invoked with all of the pending changes?
The filter that you specify will be invoked on all 1000 changes, yes. Best,
Adam