CosmosDB Graph Read optimization with ReadDocument

One of the interesting things that caught my eye in the newly released 0.3.0-preview SDK was the .limit() step optimization.
Like we saw in one of my older posts, limit() was executed client side, so you’d get the entire result set from the server and the client side sdk would filter and return it back to caller.

So let’s put this to the test in the new SDK.
We’ll run this simple query g.V().limit(10) and inspect the generated query and result:

1
{"query":"SELECT TOP 10 N_2 FROM Node N_2  WHERE IS_DEFINED(N_2._isEdge) = false"}

That’s it! You can see in the generated query now, that the SDK automatically ads the limit in the SQL query that gets sent over to the database so you can now safely use the limit() step in your Gremlin queries.

*unfortunately, count() has not changed so looking forward to the next release.

Share Comments