DEV Community


Discussion on: Why You Shouldn't Use OFFSET and LIMIT For Your Pagination

mateuszjarzyna profile image
Mateusz Jarzyna

How to implement the pagination when ID is a UUID?

siy profile image
Sergiy Yevtushenko

There should be no difference. The only problem you may meet is that UUID does not provide any consistent ordering, so output will look rather random. If this is a problem, then you may consider alternative unique ID, for example ULID.

ivoecpereira profile image
Ivo Pereira Author

Hi @mateusz ,

I would see that in the same category as the caveat I've described in the post. Having an auto-incremented ID as a key would provide you a much more efficient solution that trying to wrap the strategy around a UUID.

It would be possible to use a workaround solution using a created_at in combination with a UUID, but I would highly advise against that, as for the performance hit you will be having, you would be much better sorting by ID.

perzanko profile image
Kacper Perzankowski

I thought the same. In my opinion, incremental PKs are rarely used in mature systems.