diff --git a/couchbase2/README.md b/couchbase2/README.md index 786060da43941099e8f4f90e70f967fa6b86c273..d2b6aeea277234408508c79b8edf81dee54c949e 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 3d0bc0398c76931539859af551c42b6379a664cb..8e767096dc1361f01d0294c2423910f9d9597b41 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>>() {