title: DynamoDB Table.scan with and without pagination
body: <p>I am trying to understand the difference between two following code segments. One uses pages to get scan results, and the second one doesn't. I am wondering whether the second approach would work if the total number of items in the database is very large? AWS docs say that scan result is limited by 1 Mb. How does this affect version 2? Will it only get first 1 mb of results or would it still make database calls after each page?</p>
  
  <p>Note that I am using table.scan API, which is different from DynamoDBClient.scan api. See <a href="http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/dynamodbv2/document/Table.html" rel="nofollow">http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/dynamodbv2/document/Table.html</a> for API details.</p>
  
  <p>Version 1 (using pages):</p>
  
  <pre><code>            ItemCollection&lt;ScanOutcome&gt; items = table.scan(spec);
              items.pages().forEach(page -&gt; {
                  for (Item item : page) {
                      response.add(item);
                  }
              });
  </code></pre>
  
  <p>Version 2 (iterating over items without pages):</p>
  
  <pre><code>            ItemCollection&lt;ScanOutcome&gt; items = table.scan(spec);
              for (Item item : items) {
                      response.add(item);
              }
  </code></pre>