title: How to get total count for given time period in DynamoDB?
body: <p>Background: We have an api which different api users are calling from different companies. We are logging every request in <code>DataDog</code>. From DD, I am fetching those logs every minute, get the required data i.e. <code>apiUserKey</code>, <code>companyName</code>, <code>dateAccessed</code>, <code>apiVersion</code> etc. I am logging each of this request in a DynamoDB table called <code>EpgApiStatistics</code> as shown in the image.</p>
  <p>I can paginate through the list but I also need to maintain the total count for each api user and also the total count for each company(channel). For this purpose I have created two separate tables where I have the <code>apiUserkey</code> as partition key and <code>channelId</code> as parition key and then increment the total count.</p>
  <p>My question is how can I calculate total count for a given time period or range of time. Let's say we want to see total api calls by a user from 10th to 17th November or month etc?</p>
  <p><a href="https://i.stack.imgur.com/BWd6D.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BWd6D.png" alt="Main table with api calls details" /></a>
  <a href="https://i.stack.imgur.com/3hssT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3hssT.png" alt="Total api calls count for each api user" /></a>
  <a href="https://i.stack.imgur.com/QJ2ks.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QJ2ks.png" alt="Total api calls count for each company" /></a></p>
  <p>I have read about GSI (global secondary index) but I am confused how can I use them in my current setup. Thanks for your time.</p>