Fork me on GitHub

So I finally figured out that I should be using X-Ray, and I’m using it to debug some performance problems in my DynamoDB code. One in particular is very mysterious, this is the X-Ray view. This is using promesa/all to run a series of queries, but it looks like each one takes more time than the previous ones as if there were contention of some kind. The query is against a table using equality on the primary key of a secondary index:

(defn get-renewals
  "Given a seq of previous orders, returns a vector of renewal details for all
   of them as a promise."
  [db previous]
  (let [ids (->> previous
                 (map :order-id)
        promises (map #(dynamo/query db {:table :licence-renewals
                                         :where {:renewed-from [:= %]}
                                         :index :renewals})
    (-> (p/all promises)
        (then #(mapcat identity %)))))
This table is small (~2250 elements). Any ideas why this might be taking so long?