Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
github.com/flukis/pagination-comparation
Since i know about two strategy about pagination, i want to try how to make both and knowing how much the different between one and another, in this repo i will make a comparation between:
Pagination using page is popular way to paginate the request of batch data, it used a number like 1, 2, 3 to say that i need data from that page, let say we have 100 data and per page is 10, when we send request with page = 3
, we will get data from 21 - 30, page = 5
will get data from 41 - 50.
Litle bit different, this pagination not send page
to the server, it send next = this_is_cursor
as cursor for the next data we want, this cursor will used as filter where
in database query so we can get the next data from information in next
.
make setup
to install all needed in this go project, oh, before that you must have Golang first..env
file with your config, config consist for postgres configuration and server listener configuration.make migup
, and if you want to migrate down just type make migdown
.make run
to run the applicationhttp://127.0.0.1:8080/api/product/page?page=100000&per_page=10&sort_by=name&sort_order=DESC
http://127.0.0.1:8080/api/product/cursor?cursor=&limit=10
Seed data can in db/seeder/seed.lua
, i use Lua scripting language to generate a .sql
file that contain seeder data to table when migration up.
I use ApacheBench for load test, you can visit this page for more information site, for simplicity you can type make bench
to run benchmark using ab
a.k.a ApacheBench, or if you want to change the parameter you can look at my Makefile.
Load test on cursor based pagination
Load test on page based pagination
Test by yourself, on my machine the pagination using cursor is almost 2 times faster than pagination using page.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.