Maybe something like this
- get all post ids
- shuffle and cache id list
- use pagination with cache key
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have to display posts on multiple pages, but I want the order be always different. Unfortunately inRandomOrder() can give already displayed items by requesting another page.
orderBy(DB::raw('RAND(aseed)') or orderByRaw('RAND(aseed)') are database specific and slow on a big dataset.
What could be an efficient alternative?
Maybe something like this
Please or to participate in this conversation.