1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[SQL] Order pagination with limit and offset

Discussão em 'Outras Linguagens' iniciado por Stack, Outubro 5, 2024 às 21:42.

  1. Stack

    Stack Membro Participativo

    If I have 3000 rows.

    Page 1

    Select * from clients order by id limit 1000 offset 0;


    Page 2

    Select * from clients order by id limit 1000 offset 1000;


    Page 3

    Select * from clients order by id limit 1000 offset 2000;


    My question is about the internal processing of postgres.

    I am using the order clause to avoid duplicate entries and the consistency of the pagination.

    Page 1 1000 rows
    Page 2 1000 rows+1000 rows
    Page 3 1000 rows + 1000 rows + 1000 rows
    ....


    Therefore, the higher the page number, higher the time it will take. This is correct and normal? Or there is another approach?

    The offset and the order always need to know the previous results, right?

    Continue reading...

Compartilhe esta Página