title: Very slow save operation with DynamoDB on local machine
body: <p>I am trying to use <code>DynamoDB</code> on my local pc.
  Before I was using <code>MongoDB</code> and the performance of the <code>DynamoDB</code>  compared to it is very poor. 
  The save operation to a table takes a very long time, about 13 seconds for 100 records.
  The records are pretty small, example below.
  Here is my full example and code which I use to run it:</p>
  
  <pre><code>public class dynamoTry {
      private AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard()
              .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("http://localhost:8000", "us-east-2"))
              .build();
      private DynamoDB dynamoDB = new DynamoDB(client);
      private DynamoDBMapper mapper = new DynamoDBMapper(client);
  
      public static void main(String[] args) {
          dynamoTry dt = new dynamoTry ();
          dt .deleteTable();
          dt .buildGrid();
  
          dt .demoFill();
          dt .scanTable();    
      }
  
      public void buildGrid() {
          System.out.println("Attempting to create table; please wait...");
  
          String tableName = "Grid";
  
          List&lt;AttributeDefinition&gt; attributeDefinitions = new ArrayList&lt;AttributeDefinition&gt;();
          attributeDefinitions.add(new AttributeDefinition().withAttributeName("name").withAttributeType(ScalarAttributeType.S));
          attributeDefinitions.add(new AttributeDefinition().withAttributeName("country").withAttributeType(ScalarAttributeType.S));
  
          List&lt;KeySchemaElement&gt; keySchema = new ArrayList&lt;KeySchemaElement&gt;();
          keySchema.add(new KeySchemaElement().withAttributeName("name").withKeyType(KeyType.HASH));
          keySchema.add(new KeySchemaElement().withAttributeName("country").withKeyType(KeyType.RANGE));
  
          CreateTableRequest request = new CreateTableRequest().withTableName(tableName).withKeySchema(keySchema)
                  .withAttributeDefinitions(attributeDefinitions).withProvisionedThroughput(
                      new ProvisionedThroughput().withReadCapacityUnits(500L).withWriteCapacityUnits(500L));
  
          Table table = dynamoDB.createTable(request);
  
          try {
              table.waitForActive();
              System.out.println("Success.");
          } catch (InterruptedException e) {e.printStackTrace();}
  
      }
  
      public void demoFill() {
          final List&lt;GridPoint&gt; gpl = new ArrayList&lt;GridPoint&gt;();
          int count = 0;
  
          while (count &lt; 100) {
              final String point = "point" + count;
  
              gpl.add(makeGP(point, count, "continent", "country", new HashSet&lt;Double&gt;(Arrays.asList(22.23435, 37.89746))));
  
              count++;
          }
  
          long startTime = System.nanoTime();
          addBatch(gpl);
          long endTime = System.nanoTime();
          long duration = (endTime - startTime)/1000000; 
          System.out.println(duration + " [ms]");
      }
  
      public void addBatch(List&lt;GridPoint&gt; gpl) {
          mapper.batchSave(gpl);
      }
  
      public GridPoint makeGP(String name, int sqNum, String continent, String country, HashSet&lt;Double&gt; cords) {
          GridPoint item = new GridPoint();
          item.setName(name);
          item.setSqNum(sqNum);
          item.setContinent(continent);
          item.setCountry(country);
          item.setCoordinates(cords);
  
          return item;
      }
  
      public void scanTable() {
          Map&lt;String, AttributeValue&gt; eav = new HashMap&lt;String, AttributeValue&gt;();
          eav.put(":val", new AttributeValue().withN("0"));
          DynamoDBScanExpression scanExpression = new DynamoDBScanExpression().withFilterExpression("sqNum &gt;= :val").withExpressionAttributeValues(eav);
          List&lt;GridPoint&gt; scanResult = mapper.scan(GridPoint.class, scanExpression);
          for (GridPoint gp : scanResult) {
              System.out.println(gp);
          }
      }
  
      public void deleteTable() {
          Table table = dynamoDB.getTable("Grid");
  
          try {
              System.out.println("Attempting to delete table 'Grid', please wait...");
              table.delete();
              table.waitForDelete();
              System.out.print("Success.");
          }
          catch (Exception e) {
              System.err.println("Unable to delete table: ");
              System.err.println(e.getMessage());
          }
      }
  
  }
  </code></pre>
  
  <p>Here is the code for the <code>GridPoint</code> class:</p>
  
  <pre><code>@DynamoDBTable(tableName = "Grid")
  public class GridPoint {
      private String name;
      private int sqNum;
      private String continent;
      private String country;
      private HashSet&lt;Double&gt; coordinates; // [longitude, latitude]
  
      // Partition key
      @DynamoDBHashKey(attributeName = "name")
      public String getName() {
          return name;
      }
      public void setName(String name) {
          this.name = name;
      }
  
      @DynamoDBAttribute(attributeName = "sqNum")
      public int getSqNum() {
          return sqNum;
      }
      public void setSqNum(int sqNum) {
          this.sqNum = sqNum;
      }
  
      @DynamoDBAttribute(attributeName = "continent")
      public String getContinent() {
          return continent;
      }
      public void setContinent(String continent) {
          this.continent = continent;
      }
  
      @DynamoDBAttribute(attributeName = "country")
      public String getCountry() {
          return country;
      }
      public void setCountry(String country) {
          this.country = country;
      }
  
      @DynamoDBAttribute(attributeName = "coordinates")
      public HashSet&lt;Double&gt; getCoordinates() {
          return coordinates;
      }
      public void setCoordinates(HashSet&lt;Double&gt; coordinates) {
          this.coordinates = coordinates;
      }
  
      @Override
      public String toString() {
          return "GP {name = " + name + ", sqNum = " + sqNum + ", continent = " + continent + ", country = " + country
              + ", coordinates = " + coordinates.toString() + "}";
      }
  
  }
  </code></pre>
  
  <p>Why is it so slow? is there any way of speeding the writing process?
  In <code>MongoDB</code> the same operations would take less than a second.
  When I was running it about 3000 points it took several minutes to finish, seems not reasonable.
  Is it possible to make the batch save process parallel? would it speed things up?
  I also tried to set the <code>ProvisionedThroughput</code> parameter to a higher value but that did not help.
  I am lost, any help would be appreciated, thank you.</p>