From 5edb1d9e2c9e51ec1ea26e1504305a7090653787 Mon Sep 17 00:00:00 2001 From: Matt Ingenthron <ingenthr@cep.net> Date: Tue, 10 May 2016 18:49:30 -0700 Subject: [PATCH] [couchbase2] Change query to use RAW and ORDER BY. Using RAW queries reduces overhead at cbq-engine on the cluster and reduces transport. This in turn delivers lower latencies and thus higher throughput with YCSB's tight loops of requests. Adding an ORDER BY maintains strict correctness with the intended implementation of Workload E. In this particular case, the ORDER BY is effectively a noop since the index in use is ordered anyway. The README for couchbase2 was also updated to reflect the simpler index creation which is possible with Couchbase Server 4.5. Server 4.5 automatically covers on the primary index so there is no need for the more complicated syntax unless using an older version. Note this change requires the 2.3.1 Couchbase Java SDK and its underlying core-io 1.3.1. The core-io 1.3.1 adds a streaming parser for RAW results. --- couchbase2/README.md | 9 ++++++++- .../com/yahoo/ycsb/db/couchbase2/Couchbase2Client.java | 9 +++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/couchbase2/README.md b/couchbase2/README.md index 786060da..d2b6aeea 100644 --- a/couchbase2/README.md +++ b/couchbase2/README.md @@ -65,7 +65,14 @@ For `workloade` and the default `readallfields=true` we recommend creating the f Server 4.5 or later with the "Memory Optimized Index" setting on the bucket. ``` -CREATE INDEX wle_idx ON `bucketname`(meta().id); +CREATE PRIMARY INDEX ON `bucketname`; +``` + +Couchbase Server prior to 4.5 may need a slightly different index to deliver the best performance. In those releases +additional covering information may be added to the index with this form. + +``` +-CREATE INDEX wle_idx ON `bucketname`(meta().id); ``` For other workloads, different index setups might be even more performant. diff --git a/couchbase2/src/main/java/com/yahoo/ycsb/db/couchbase2/Couchbase2Client.java b/couchbase2/src/main/java/com/yahoo/ycsb/db/couchbase2/Couchbase2Client.java index 3d0bc039..8e767096 100644 --- a/couchbase2/src/main/java/com/yahoo/ycsb/db/couchbase2/Couchbase2Client.java +++ b/couchbase2/src/main/java/com/yahoo/ycsb/db/couchbase2/Couchbase2Client.java @@ -149,7 +149,8 @@ public class Couchbase2Client extends DB { boost = Integer.parseInt(props.getProperty("couchbase.boost", "3")); networkMetricsInterval = Integer.parseInt(props.getProperty("couchbase.networkMetricsInterval", "0")); runtimeMetricsInterval = Integer.parseInt(props.getProperty("couchbase.runtimeMetricsInterval", "0")); - scanAllQuery = "SELECT meta().id as id FROM `" + bucketName + "` WHERE meta().id >= '$1' LIMIT $2"; + scanAllQuery = "SELECT RAW meta().id FROM `" + bucketName + + "` WHERE meta().id >= '$1' ORDER BY meta().id LIMIT $2"; try { synchronized (INIT_COORDINATOR) { @@ -632,11 +633,7 @@ public class Couchbase2Client extends DB { .flatMap(new Func1<AsyncN1qlQueryRow, Observable<RawJsonDocument>>() { @Override public Observable<RawJsonDocument> call(AsyncN1qlQueryRow row) { - String id = new String(row.byteValue()); - return bucket.async().get( - id.substring(id.indexOf(table + SEPARATOR), id.lastIndexOf('"')), - RawJsonDocument.class - ); + return bucket.async().get(new String(row.byteValue()), RawJsonDocument.class); } }) .map(new Func1<RawJsonDocument, HashMap<String, ByteIterator>>() { -- GitLab