title: server timeout on Dynamo DB query operation to get items from a table
body: <p>I have an array of ids (<code>eventids</code>) which can be million or billion ids inside the table. I am using a for loop to go through each id and retrieve an item from a dynamo db table using the query operation in PHP. However, because the query operation goes over a large amount of info in my table, it takes too long the query operation to do its work.  So, in this case I don't get any result because I get a time out. The following code tries to do this operation, which is failing for large amounts of info. I am wondering if you have any recommendation or suggestions on how to make the query operation faster and doable for large amounts of ids inside the <code>$sfweventarrayRDS</code> array?</p>
  
  <pre><code>    for ($j = 0 ; $j &lt; count($sfweventarrayRDS) ; $j++){
          $keyconditions = array(
              "eventid" =&gt; array(
                  "ComparisonOperator" =&gt; ComparisonOperator::EQ,
                  "AttributeValueList" =&gt; array(
                      array(Type::NUMBER =&gt; $sfweventarrayRDS[$j]["eventid"])
                  )
              )
          );
  
          $sfweventarrayDynamo = Dynamo::getItems("eventlocation",$keyconditions,$limit);
  
          if (count($sfweventarrayDynamo) &gt; 0){
  
              $timediffepoch = $sfweventarrayDynamo[0]["edatecreated"]["N"] - $sfweventarrayRDS[$j]["edatecreated"];
              $timediffstandard = new DateTime("@$timediffepoch");
  
              if ($timediffstandard-&gt;format('i') &gt;= 5){
                  $starttimeepoch = $sfweventarrayRDS[$j]["edatecreated"];
                  $endtimeepoch = $sfweventarrayDynamo[0]["edatecreated"]["N"];
                  $starttimestandard = new DateTime("@$starttimeepoch");
                  $endtimestandard = new DateTime("@$endtimeepoch");
  
                  $each_event = array("eventid" =&gt; $sfweventarrayDynamo[0]["eventid"]["N"], 
                                      "organizationid" =&gt; $sfweventarrayRDS[$j]["organizationid"],
                                      "userid" =&gt; $sfweventarrayDynamo[0]["userid"]["N"],
                                      "starttime" =&gt; $starttimestandard-&gt;format('Y-m-d H:i:s'), 
                                      "endtime" =&gt; $endtimestandard-&gt;format('Y-m-d H:i:s'),
                                      "location" =&gt; $sfweventarrayRDS[$j]["location"],
                                      "startlatitude" =&gt; $sfweventarrayRDS[$j]["latitude"],
                                      "startlongitude" =&gt; $sfweventarrayRDS[$j]["longitude"],
                                      "endlatitude" =&gt; $sfweventarrayDynamo[0]["latitude"]["N"],
                                      "endlongitude" =&gt; $sfweventarrayDynamo[0]["longitude"]["N"]);
                  array_push($safewalkeventsDynamo, $each_event);
              }
          }
      }
  </code></pre>