If you are wondering why lemmy is moving away from offset pagination since 0.19, here is a nice article about it

      • Max-P
        link
        fedilink
        67 months ago

        Lemmy just implemented it for 0.19 and it makes a big difference on heavier queries like Scaled homepage.

        It also has the advantage of your pagination not getting screwy if new content has been added between page 2 and 3 queries.

      • @[email protected]
        link
        fedilink
        17 months ago

        I have my doubts about the technique, but it could be useful in certain controlled situations

        This is completely uncontroversial advice and has been for 30 years. What are your doubts exactly?

        I’d go further: if you see a query that uses “offset” on a non-trivial production DB something is very, very wrong.

        Of course, the trick is that you need to make sure you have indexes for all sort orders you need to display, but that’s obvious.

    • @starmanOP
      link
      English
      17 months ago

      Sorry, I updated the link

  • Enitoni
    link
    fedilink
    47 months ago

    Account-wall. Please provide a link that doesn’t force me to make an account.

    • @starmanOP
      link
      English
      27 months ago

      Sorry, link updated

  • @lysdexic
    link
    English
    47 months ago

    For the article-impaired,

    Using OFFSET+LIMIT for pagination forces a full table scan, which in large databases is expensive.

    The alternative proposed is a cursor+based navigation, which is ID+LIMIT and requires ID to be an orderable type with monotonically increasing value.

    • @[email protected]
      link
      fedilink
      English
      26 months ago

      Which it almost never is.

      Any data as simple as that is unlikely to reach a number of rows likely to cause an issue with performance.

    • @lysdexic
      link
      English
      1
      edit-2
      7 months ago

      Having said this, I’d say that OFFSET+LIMIT should never be used, not because of performance concerns, but because it is fundamentally broken.

      If you have rows being posted frequently into a table and you try to go through them with OFFSET+LIMIT pagination, the output from a pagination will not correspond to the table’s contents. Fo each row that is appended to the table, your next pagination will include a repeated element from the tail of the previous pagination request.

      Things get even messier once you try to page back your history, as now both the tip and the tail of each page will be messed up.

      Cursor+based navigation ensures these conflicts do not happen, and also has the nice trait of being easily cacheable.

  • @[email protected]
    link
    fedilink
    English
    27 months ago

    Is there a way I can access this article without making an account?

    I’m not going to make an account.

    • @starmanOP
      link
      English
      47 months ago

      Sorry for inconvenience, I updated the link

      • @[email protected]
        link
        fedilink
        English
        27 months ago

        Oh thanks mate 👍

        Interesting article but I kinda fail to see how you’d go if your paginating through sorted rows - you’d have to have an id in the sequence of your sort order?