Can I get the total number of records that meet the conditions of a query using the Table API?

Hello

A < row > TableIterator is returned when I ask operations using the index of tables. If I want to get the total number of records, I count one by one using the returned TableIterator < row >.


Can I get the total number of records directly meets the conditions of the query?

I can get the total number of records directly the request of the meeting of the conditions of CLI using the command Global table - name tableName - count - index index-name-field fieldName - start startValue-end endValue.

Can I get the same results using the Table API?

I used MongoDB and NoSQL Oracle for about a year. According to the experience of the use of these dbs, I think mongoDB querying interface is powerful. In the contras, the query interface is relatively simple, which results is a lot of work that is usually a long time in the client side.

Hello

Counting records in a database is a tricky thing.  Any system that gives you an accurate count of the records will have a hotspot of concurrency on updates, namely the place where the counting is maintained.  Such a count is a problem of performance in addition to competitive access problem.   The problem is even more difficult in a system widely distributed such a NoSQL database.

The CLI has overall command that counts, but does so by brutal force - iterate keys that correspond to the parameters of the operation.  This is how you must do this within the API.  There is not a lot of code, but you have to write.  You certainly want to use TableIterator TableAPI.tableKeysIterator (), because a key iteration is significantly faster than the iteration of lines.  Just one iteration and count.

If you use TableAPI.multiGet () and a key with a touch of brightness full then, in fact, count the results as they are returned in a single piece (a list).

Kind regards

George

Tags: Database

Similar Questions

Maybe you are looking for