Skip to content

Commit

Permalink
Optimize 1st-time pull by skipping deleted docs
Browse files Browse the repository at this point in the history
Send "?active_only=true" as a _changes feed parameter when there's no
"since" parameter, to tell SG 1.2+ to skip sending deleted (or removed)
docs. This can speed up the initial pull quite a lot.

Fixes #1052 (see also couchbase/sync_gateway#1503 )
  • Loading branch information
snej committed Jan 23, 2016
1 parent 9928d54 commit eef3f86
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Source/ChangeTracker/CBLChangeTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ - (NSString*) changesFeedPath {
if ([seq isKindOfClass: [NSArray class]] || [seq isKindOfClass: [NSDictionary class]])
seq = [CBLJSON stringWithJSONObject: seq options: 0 error: nil];
[path appendFormat: @"&since=%@", CBLEscapeURLParam([seq description])];
} else {
// On first replication we can skip getting deleted docs. (SG enhancement in ver. 1.2)
[path appendString: @"&active_only=true"];
}
if (_limit > 0)
[path appendFormat: @"&limit=%u", _limit];
Expand Down Expand Up @@ -162,6 +165,7 @@ - (NSData*) changesFeedPOSTBody {
NSMutableDictionary* post = $mdict({@"feed", self.feed},
{@"heartbeat", @(round(_heartbeat*1000.0))},
{@"style", (_includeConflicts ? @"all_docs" : nil)},
{@"active_only", (since ? nil : @YES)},
{@"since", since},
{@"limit", (_limit > 0 ? @(_limit) : nil)},
{@"filter", filterName},
Expand Down

0 comments on commit eef3f86

Please sign in to comment.