获得徽章 0
#Offset pagination vs Cursor pagination

Cursor pagination is most often used for real-time data due to the frequency new records are added and because when reading data you often see the latest results first. There different scenarios in which offset and cursor pagination make the most sense so it will depend on the data itself and how often new records are added. When querying static data, the performance cost alone may not be enough for you to use a cursor, as the added complexity that comes with it may be more than you need.

Offset pagination allows you to jump to any page, while in Cursor-based pagination, you can only jump into the next/previous page.

There is also a substantial difference in the implementation underneath. The Offset will very likely have to load all the records from the first page to the page you want to get. There are techniques to avoid this.

More: ignaciochiazzo.medium.com
展开
评论
清香苦茶的头像
前端工程师 @ 潜水大师
清香苦茶的头像
前端工程师 @ 潜水大师
清香苦茶的头像
前端工程师 @ 潜水大师
清香苦茶的头像
前端工程师 @ 潜水大师
问:reduce方法有初始值和没有初始值的区别

reduce函数的第一个参数是一个回调函数,第二个参数为可选的初始值。

如果有初始值的话,回调函数就会从数组的第0项开始执行,也就是会执行arr.length次;

但是如果没有初始值的话,会默认取数组的第0项为初始值,回调函数会从数组的第1项开始执行,也就是会执行arr.length - 1次。
展开
清香苦茶于2021-09-02 15:29发布的图片
5
下一页
个人成就
文章被点赞 33
文章被阅读 5,121
掘力值 353
收藏集
1
关注标签
55
加入于