starman@programming.dev to Programming@programming.devEnglish · edit-210 months agoWhy You Shouldn’t Use OFFSET and LIMIT For Your Paginationivopereira.netexternal-linkmessage-square9fedilinkarrow-up13arrow-down10file-text
arrow-up13arrow-down1external-linkWhy You Shouldn’t Use OFFSET and LIMIT For Your Paginationivopereira.netstarman@programming.dev to Programming@programming.devEnglish · edit-210 months agomessage-square9fedilinkfile-text
If you are wondering why lemmy is moving away from offset pagination since 0.19, here is a nice article about it
minus-squarelysdexic@programming.devlinkfedilinkEnglisharrow-up1·10 months agoFor 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.
minus-squareBlackmist@lemmy.worldlinkfedilinkEnglisharrow-up2·9 months agoWhich 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.
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.
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.