> On Aug 27, 2014, at 2:17 AM, Chris H <[email protected]> wrote:
> 
> New to Couchbase Lite iOS and have 350,000 documents in a bucket.
…
> I'm having real problems with view speed, firstly trying to grab close 
> locations will take 30 seconds for the first query, and subsequent ones are 
> fast.

So it's indexing about 2k docs/sec. (What hardware is this on?)

>               if ([doc[@"type"] isEqualToString:@"location"]) {
>                       emit(CBLGeoPointKey([doc[@"lat"] doubleValue], 
> [doc[@"lon"] doubleValue]), doc[@"name"]);

The map function looks reasonable. I've never benchmarked views that use 
SQLite's Rtree (geo) indexing, so I don't know how much of the time is taken up 
by that. You could try profiling the indexing using Instruments' time profiler. 
It'd be interesting to know how much of the time is spent inside SQLite.

> I assume most of the time is from indexing the database (since subsequent 
> queries are fast),

Correct.

> is there any way to automatically index the database as soon as it is synced?

I've considered doing that, but I don't think it would save time. Instead, the 
pull replication would just take 30 seconds longer … quite possibly more than 
that since the batch indexing has economies of scale that would be lost if 
indexing individual docs.

You could get the same effect by waiting for the initial pull to complete, then 
triggering an async query with limit=1 to update the view index in the 
background, then waiting for that to complete before telling the user that the 
data is available.

—Jens

-- 
You received this message because you are subscribed to the Google Groups 
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/9EA0A269-A539-498D-A484-B7C51866FCD9%40couchbase.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to