Using Last is slow

I am new to ShipHero + Graphql - I’ve been trying to run a few queries, and I’ve been noticing that using a filter for (first:1) is fast, but using (last:1) is extremely slow (if it completes)… Is this normal?

Hi @statonjm !
It might have an overhead due to the iteration it does until it reaches last, shouldn’t be that bad though
Another handy filter you could use (in case you haven’t used it already) is the sort filter.

For example if you want to sort by created_at DESCENDING, you have to enter sort:"-created_at" while if you want to sort by created_at ASCENDING, you have to enter sort:"created_at"

Hope it helps!,


@tomasw thanks for the tip! Sorting in descending order while using first worked extremely fast!

Out of curiosity, if one was paginating through records (sort by created in desc, taking first:1), and a new record was made while paginating, would this affect the results?

E.g. If I am paginating through the POs in descending order, I have 10 pages and I am currently on page 5 when a new PO is created… Would this mean there is now 11 pages, and when I call page 6 it is really just the same PO which I had just previously called (was on page 5)?

Just trying to understand pagination in general so I can write my workflows correctly!

1 Like

Glad it helped!

Yes, to my understanding, cursors are dynamic in that sense, so if records are changed we can no longer “safely” assume that cursor will be the one expected

1 Like

Excellent, thanks for that info, definitely helps me understand how to make a robust solution (or what potential mistakes to avoid!)

1 Like