I need to retrieve 50.000 entities from my Azure Storage Table and the result should be put in a List
. Retrieving the entities does not take much time but putting them from an Iterable
into a List
takes relatively long, around 10 seconds. How can I do this in less time?
The following code retrieves the entries and puts them into an ArrayList
:
Iterable<T> items = table.execute(tableQuery);
ArrayList<T> result = new ArrayList<T>();
if (items != null) {
for (T item : items) {
result.add(item.getContents());
}
}
Only 1000 entries at a time are retrieved but the Iteratable
handles this automatically from my understanding. This also seems to be the time consuming part, getting the next 1000 entries each time.
I also tried this with executeSegmented
and ResultContinuation
tokens:
ArrayList<T> result = new ArrayList<T>();
ResultContinuation token = null;
do {
ResultSegment<T> segment = table.executeSegmented(tableQuery, token);
result.addAll(segment.getResults());
token = segment.getContinuationToken();
} while (token != null);
Here the executeSegmented
takes a lot of time.
So these options are both to slow. How can I get higher performance to create this List
faster?
Edit
The query is as following:
TableQuery<T> tableQuery = TableQuery.from(classAzure).where(TableQuery.generateFilterCondition("MerchantId", QueryComparisons.EQUAL, merchantId));