https://github.com/ilias-ant/keyset-pagination-demo
A nit comparison between offset-based pagination and keyset pagination.
https://github.com/ilias-ant/keyset-pagination-demo
keyset-pagination offset performance-analysis pgbench postgresql
Last synced: 3 months ago
JSON representation
A nit comparison between offset-based pagination and keyset pagination.
- Host: GitHub
- URL: https://github.com/ilias-ant/keyset-pagination-demo
- Owner: ilias-ant
- License: apache-2.0
- Created: 2023-06-26T09:39:59.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-06-26T21:18:12.000Z (almost 2 years ago)
- Last Synced: 2025-03-15T03:14:43.972Z (3 months ago)
- Topics: keyset-pagination, offset, performance-analysis, pgbench, postgresql
- Language: PLpgSQL
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# keyset-pagination-demo
A nit comparison between offset-based pagination and keyset pagination.## Setup
Spin up a PostgreSQL instance with:
```bash
docker compose up -d
```Then, open a bash shell inside the running db container with:
```bash
docker compose exec -it db bash
```and run the following command to perform a benchmark comparison between offset-based pagination and keyset pagination,
with 10 million rows as a testbed and 100 iterations for the benchmarking:```bash
# -n: number of rows to insert
# -i: number of benchmarking iterations
sh /var/lib/postgresql/scripts/run.sh \
-n 10000000 \
-i 100
```Feel free to change `-n` and `-i` values to your liking.
# Notes
- `db/init.sql` has been created by prompting [chatGPT](https://en.wikipedia.org/wiki/ChatGPT) (out of boredom),
so `populate_tables` function may not be optimal.
- [pgbench](https://www.postgresql.org/docs/current/pgbench.html), a simple program for running benchmark tests on
PostgreSQL, is used for the benchmarking.
- `results/` contain the original benchmarking experiments.