mirror of
https://github.com/google/nomulus.git
synced 2025-05-20 11:19:35 +02:00
Fix Datastore "count" queries (#1201)
* Fix Datastore "count" queries The objectify "count()" method doesn't work for result sets larger than 1000 elements, use the original trick from "count domains" that fetches the keys and counts them. * Added an SO link
This commit is contained in:
parent
3f5ba9cfef
commit
dad3fcca9a
1 changed files with 7 additions and 1 deletions
|
@ -480,7 +480,13 @@ public class DatastoreTransactionManager implements TransactionManager {
|
|||
|
||||
@Override
|
||||
public long count() {
|
||||
return buildQuery().count();
|
||||
// Objectify provides a count() function, but unfortunately that doesn't work if there are
|
||||
// more than 1000 (the default response page size?) entries in the result set. We also use
|
||||
// chunkAll() here as it provides a nice performance boost.
|
||||
//
|
||||
// There is some information on this issue on SO, see:
|
||||
// https://stackoverflow.com/questions/751124/how-does-one-get-a-count-of-rows-in-a-datastore-model-in-google-app-engine
|
||||
return Iterables.size(buildQuery().chunkAll().keys());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue