Repo.paginate and Repo.all

I am trying get the same result from a query, either using Repo.all and Repo.paginate. Repo.all returns the correct results but Repo.paginate returns different results. The queries are demonstrated below. Help me Understand why this is so
Cust_account
|> where([a], a.product_name == “Wood”)
|> order_by(desc: :amount)
|> limit(10)
|> Repo.all

        Cust_account
        |> where([a], a.product_name ==  "Wood")
        |> order_by(desc: :amount)
        |> limit(10)
        |> Repo.paginate(page: page, page_size: 10)

The two queries select the same thing but bring different number of results. Help me understand why the two behave differently.

It’s because you have defined page_size: 10 which will give you those numbers of records on page 1. If I’m not wrong that is what it is.

The first query is equivalent to getting the first page using Repo.paginate.
What is the value in page? If it is >1, then the answer should be obvious.
Also, try to compare logged SQL queries.

I agree with that. So the question is does Repo.paginate allow limit off set in queries and produce expected results?

It depends on a library you’re using for pagination. I assume Repo.paginate will overwrite limit and offset keys in a query. This can be easily checked by comparing SQL queries.