home shape

Improved Cursor API: ArangoDB Query Efficiency Boost

This week we pushed some modifications for ArangoDB’s cursor API into the devel branch. The change will result in less copying of AQL query results between the AQL and the HTTP layers. As a positive side effect, this will reduce the amount of garbage collection the built-in V8 has to do.

These modifications should improve the cursor API performance significantly for many cases, while at the same time keeping its REST API stable. Client programs do not need to be adjusted to reap the benefits. In a blog post, Jan shows some first unscientific performance tests comparing the old cursor API with its new, improved implementation.

The new cursor API was faster than its old counterpart for all queries tested. Total execution time as measured by the ArangoShell (representative for any other client program sending queries to ArangoDB) was consistently lower than it was with the old API implementation.

Test function used in the performance test

var test = function(query, n) {
  var time = require("internal").time;
  var s = time();
  for (var i = 0; i < n; ++i) {
    db._query(query).toArray();
  }
  return time() - s;
};

The test function was run with different queries to check which types of queries will benefit from the cursor API change. Here’s one of the queries, resulting in 10,000 calls to the cursor API:

test("RETURN { one: 'test', two: 'another-value', three: [ 1, 2, 3 ] }", 10000);

This took 8.046 s with the old API, and 5.829 s with the new one (27 % improvement).

The improvements measured were varying. For the queries tested, the improvements fell into a range of 10 % to even more than 50 % improvement.

Please read the full blog post Improvements for the Cursor API.

Ingo

Ingo Friepoertner

Ingo is dealing with all the good ideas from the ArangoDB community, customers and industry experts to improve the value provided by the company’s native multi-model approach. In former positions he worked as a product owner and tech consultant, building custom software solutions for large companies in various industries. Ingo holds a diploma in business informatics from FHDW University of Applied Sciences.

Leave a Comment





Get the latest tutorials, blog posts and news: