Couchbase Performance -
i have couchbase community edition v4, build 4047. seems great until started issuing queries against simple view. view projecting documents so, seems harmless:
function (doc, meta) { if(doc.applicationid){ emit(doc.applicationid,meta.id); } }
i'm using .net client connect , execute query application, though don't think matters. it's single node configuration. i'm clocking time in between actual http requests , queries taking between 4 seconds on 2 minutes if send 15 requests in @ time through fiddler.
i using stale index try , boost time, doesn't seem have impact. bucket not large. there couple of documents in bucket. i've allocated 100m ram indexing. i'd think that's fine @ least few documents we're working @ moment.
this local development, observing similar behaviors when promoted our servers. servers don't use significant amount of ram either, @ same time aren't storing significant amount of documents. we're talking 10 or 20 @ most? these documents contain 5 primitive-type properties.
do have suggestions diagnosing this? logs through couchbase admin console don't show unusual far can tell , doesn't seem normal behavior.
update: here code query documents
public async task expirecurrentsession(string applicationid) { using (var bucket = getsessionbucket()) { var query = bucket .createquery("activesessions", "activesessionsbyapplicationid") .key(applicationid) .stale(couchbase.views.stalestate.ok); var result = await bucket.queryasync<string>(query); foreach (var session in result.rows) { await bucket.removeasync(session.value); } } }
the code seems fine, , should work expect. 100mb ram mention allocating isn't views, affects n1ql global secondary indexes. brings me following suggestion:
you don't need use view in couchbase 4.0; can use n1ql simpler , (probably) more efficiently.
create n1ql index on applicationid
field (either in code of cbq
command line shell) so:
create index ix_applicationid on bucketname(applicationid) using gsi;
you can use simple select
query relevant document ids:
select meta(bucketname) bucketname applicationid = '123';
or simpler, can use delete
query delete them directly:
delete bucketname applicationid = '123';
note dml statements, delete
still considered beta feature in couchbase 4.0, own risk assessment.
to run n1ql queries .net use same syntax views:
await bucket.queryasync<dynamic>("query goes here");
Comments
Post a Comment