Bhavesh

Bhavesh

Hi :wave:

I am trying to get the data paginated, and I am trying all the methods and actions but still stuck while doing that. here is the methods I tried


   read :list do
      pagination do
        keyset? true
        offset? true
        countable true
        default_limit 10
      end
    end
 read :list do
      pagination do
        offset? true
        countable true
        default_limit 10
      end

      filter expr(true)
    end

I found all the result variables like count,more, before, after but while reading the documentation i found that the methods gives counts expect i got “nil” and for list i am doing this,

  1. List item
 allcontect =
      People
      |> Ash.Query.for_read(:list)
      |> Ash.read!()
  1. List item with count and pagination
 page = 1
    limit = 10
    offset = (page - 1) * limit

    allcontect =
      People
      |> Ash.Query.for_read(:list)
      |> Ash.Query.limit(limit)
      |> Ash.Query.offset(offset)
      |> Ash.read!()

It give me only first 10 records but I am not able to fetch others while handling next_page and previous_page events.

Showing Posts 1 to 7

zachdaniel

zachdaniel

Creator of Ash

Take a look at the pagination guide: Pagination — ash v3.29.3

Pagination is done via Ash.Query.page or via the page option to Ash.read, i.e

query
|> Ash.Query.page(limit: 10, offset: 20, count?: true)

or

Ash.read!(page: [limit: 10, offset: 20, count?: true])
Bhavesh

Bhavesh OP

Thanks, it’s very help-full for me i used this,

Ash.read!(page: [limit: 10, offset: 20, count?: true])

this is working actually and i tested for thousands of data but i am wondering it can help me to handle millions of data or not?

olivermt

olivermt

As long as your offset or keyset page id is indexed that is fine (and PKs generally are).

Bhavesh

Bhavesh OP

Thanks! That makes sense.

zachdaniel

zachdaniel

Creator of Ash

Look into keyset pagination. It will perform well on practically any amount of data with properly indexed data

dimitarvp

dimitarvp

Link (v3.5.6 as of 2025-APR-18): Ash Keyset Pagination

btw, is this relating to cursor pagination? :thinking: I can’t find it mentioned anywhere.

Or, since we are here on this topic, is keyset pagination the same as e.g. “give me 20 records where ID is greater than 157”?

zachdaniel

zachdaniel

Creator of Ash

Yes. I should add “also known as cursor pagination” somewhere on that page to make it easier to find.

edit: done

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
water
I’m aware of 2 such projects, are there others? git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
peck
Hi everyone. My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
bradley
I really like the adapter patterns that ecto, nebulex, waffle, etc. use and would love find something similar for a key management servic...
New
unaware8150
Hello folks! So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
leoschweizer
Hi, we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New
csmr
Hi all, I’m new here and would like to hear peoples views on my Elixir/Phoenix based game-engine! :smiley: Mutonex gamedesign was finish...
New

Other Trending Topics Top

mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
budgie
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with. But I don’t use it anymore. Serverless was the promis...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews