Skip to content
Snippets Groups Projects
Commit 5edb1d9e authored by Matt Ingenthron's avatar Matt Ingenthron
Browse files

[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.
parent 3fb3ab90
No related branches found
No related tags found
No related merge requests found
......@@ -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.
......
......@@ -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>>() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment