Test performance of different types of idempotency keys in Postgres:
- uuid v1 (
uuid
type): 16 bytes, monotonic increasing. - uuid v4 (
uuid
type): 16 bytes, random. - snowflake (
bigint
type): 8 bytes, monotonic increasing.
go build -o iktest ./...
-
Start your local Postgres server.
-
Visudo to enable no-password access for
purge
under Mac:%admin ALL=NOPASSWD: /usr/sbin/purge
-
Set environment variable
$DSN
for convenience:export DSN='postgres://iktest@localhost/iktest?sslmode=disable'
-
Run the program with 1,000 items:
./iktest $DSN -n 1000
-
Run the program in verbose mode:
./iktest $DSN -v
-
If everything is ok, run the program with 1,000,000 items:
./iktest $DSN -n 1000000
You may see the output similar to this:
If the database server runs on a remote host, you need to clear the cache and restart it manually when needed.
-
Set environment variable
$DSN
for convenience:export DSN='postgres://iktest@example.com/iktest?sslmode=disable'
-
Run the program with
-p
flag:./iktest $DSN -p
Every time you see the prompt:
NOTE: Please clear PostgreSQL cache, and press ENTER when done...
You'll need to clear the database cache and restart it manually. After that, press ENTER to resume the test program.
Apache License 2.0. See the LICENSE file.