Getting the number of records in a set

Is there any function in the C client library to find out the number of records present in a given set? Aql shows this in ‘objects’ column. Is the same data available via the C client library as well?

Use aerospike_info_any() with request string in format: sets/{namespace}/{set}

char* res = NULL;
as_status status = aerospike_info_any(as, &err, NULL, "sets/test/myset", &res);

The result string will look something like this:


You are responsible for parsing the “objects” value from this string and destroying string when done.

1 Like

In a multi-node cluster, will this function return the number of total objects or the number of objects stored on a particular node?

The function will return the total objects for the entire cluster in that namespace/set.

Hi Brian,

My observation was different. Please find below the details. Replication factor: 1 No. of nodes: 2

aerospike_info_any returned the count of objects on just 1 of the 2 nodes(The count was returned from the node which I had given to “aerospike_init()”).

Therefore, I used, aerospike_info_foreach() to get the count from each node and then summed them and divided by the replication factor(which was 1 in this case), to get the correct total count.

Sorry, my mistake. The object count is indeed per node. Getting the count from each node, summing and then dividing by replication factor is correct.

1 Like

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.

© 2015 Copyright Aerospike, Inc. | All rights reserved. Creators of the Aerospike Database.