Gateway Timeout for Historical Orders Query

Hello,

For historical orders queries we are consistently getting 504 Gateway Timeouts.
We are paginating through all orders over the past 5 years, and have been able to get 10,000+ orders before this issue started sporadically popping up.

We have already tried reducing the number of orders requested at a time.

Currently, the start of our query that keeps timing out is:

query {
  orders(updated_from: "2019-02-06T04:12:26") {
    data(first: 25, after: "YXJyYXljb25uZWN0aW9uOjE3MTQ5") {

Can you please suggest why this request is sporadically timing out?

Thanks,
Ryan

Hi @rypaul12!

Can you share a request ID so I can dig deeper?

However, with what you shared, I can tell you even if you are pulling the first 25, you are still going through the whole dataset of all order updates from that date. So even when it is not timing out, which is 180 secs in our API, every call might take as long as ~179 seconds.

I would suggest you further constrain the call by using an updated_to. You can try grabbing an entire month using both arguments, paginating through it, and jumping to the following one when you are done.

Have a nice day!
TomasFD

Thanks Tomas! Adding the updated_to helped a lot and I’m no longer running into any issues.
Out of curiosity are there any other optimizations I could make (perhaps something with the sort)?

Hey @rypaul12!

Glad to hear that!

The thing about containing between dates is that it lets you pick a predefined amount of dates that you can control and once you are done jump onto the next period. The rest of the filters you can use, will require you to know all the values that filter can have, and run them all for each date period.

These are your available filters:

  $shop_name: String,
  $partner_order_id: String,
  $order_number: String,
  $warehouse_id: String,
  $allocated_warehouse_id: String,
  $fulfillment_status: String,
  $sku: String,
  $email: String,
  $updated_from: ISODateTime,
  $updated_to: ISODateTime,
  $order_date_from: ISODateTime,
  $order_date_to: ISODateTime,
  $customer_account_id: String,
  $operator_hold: Boolean,
  $address_hold: Boolean,
  $payment_hold: Boolean,
  $fraud_hold: Boolean,
  $ready_to_ship: Boolean,
  $profile: String,
  $tag: String,

Adding any of those will add more work to you data retrieval I think.

Have a nice day!
TomasFD