absinthe-graphql / absinthe_relay

Absinthe support for the Relay framework
MIT License
181 stars 88 forks source link

Why using offset-based pagination in Connection.from_query? #190

Closed Menkir closed 3 years ago

Menkir commented 3 years ago

Hey guys. Why is the offset queried for Connection.from_query instead of using the where clause for a cursor ? For very large tables the runtime increases linearly because we have to skip the offset every time we want to iterate quickly through the table.

Perhaps I have not quite understood something here. I will be glad if you enlighten me :)

cheers

benwilson512 commented 3 years ago

@Menkir The Connection helper functions are designed to allow anyone to get going easily, while also providing ways to customize how things work by using from_slice.

from_query uses offset based pagination because it's the only form of pagination that is guaranteed to work for every user without assumptions about how their data works. It is expected that as users take on more advanced use cases with larger data that they start querying manually and using from_slice to generate return values.