When I create a new Vertex in CosmosDB Gremlin API I believe there is a hidden _ts
property that gets added to the record. This appears to be the default return order of vertices when performing a query, such as g.V().has('orgKey', ABC)
, my results come back in ascending order (oldest first).
Is there a way to change the default return order in CosmosDB GremlinAPI so that I get my results back newest first by default?
I am trying to avoid a full set scan when finding the newest record matching a clause and it seems I can do that easily if I can reverse the default order in which records are returned.
Query I currently have to write:
g.V().has('partitionKey', 1111).has('name', 'test-data').order().by('createdOn', decr).range(0, 10)
Query I want to be able to write
g.V().has('partitionKey', 1111).has('name', 'test-data').range(0, 10)
There is not, and the return order is technically based on rid not ts, The default return order is rid, However, order by with range does not imply a scan It will only fetch the range from the backend That does not stand in a more complex case where the ordering is not directly on the element. If you think it is doing a full scan, connecting the execution profile may give you more insight