Skip to content

A nit comparison between offset-based pagination and keyset pagination.

License

Notifications You must be signed in to change notification settings

ilias-ant/keyset-pagination-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

keyset-pagination-demo

A nit comparison between offset-based pagination and keyset pagination.

Setup

Spin up a PostgreSQL instance with:

docker compose up -d

Then, open a bash shell inside the running db container with:

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:

# -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 (out of boredom), so populate_tables function may not be optimal.
  • pgbench, a simple program for running benchmark tests on PostgreSQL, is used for the benchmarking.
  • results/ contain the original benchmarking experiments.