{"id":19458769,"url":"https://github.com/lchsk/postgresql_transactions","last_synced_at":"2026-05-15T01:39:15.573Z","repository":{"id":70291256,"uuid":"261583734","full_name":"lchsk/postgresql_transactions","owner":"lchsk","description":"Benchmarking concurrent operations in PostgreSQL","archived":false,"fork":false,"pushed_at":"2020-05-29T13:41:05.000Z","size":158,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-04T02:50:28.637Z","etag":null,"topics":["benchmark","cpp","cpp17","isolation-level","postgres","postgresql","sql","transaction","transactions"],"latest_commit_sha":null,"homepage":"https://lchsk.com","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lchsk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-05T21:09:30.000Z","updated_at":"2020-05-29T13:41:08.000Z","dependencies_parsed_at":"2023-03-01T04:31:14.820Z","dependency_job_id":null,"html_url":"https://github.com/lchsk/postgresql_transactions","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lchsk/postgresql_transactions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lchsk%2Fpostgresql_transactions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lchsk%2Fpostgresql_transactions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lchsk%2Fpostgresql_transactions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lchsk%2Fpostgresql_transactions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lchsk","download_url":"https://codeload.github.com/lchsk/postgresql_transactions/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lchsk%2Fpostgresql_transactions/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33050592,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"online","status_checked_at":"2026-05-14T02:00:06.663Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["benchmark","cpp","cpp17","isolation-level","postgres","postgresql","sql","transaction","transactions"],"created_at":"2024-11-10T17:28:27.703Z","updated_at":"2026-05-15T01:39:15.547Z","avatar_url":"https://github.com/lchsk.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PostgreSQL concurrent transactions benchmark\n\nBenchmark a number of different operations in Postgres. It simulates a concurrent environment with different transaction isolation levels.\n\n- Article describing the results of this benchmark: https://lchsk.com/benchmarking-concurrent-operations-in-postgresql.html\n\n- Context about transactions and concurrent behavior in PostgreSQL: https://lchsk.com/database-transactions-concurrency-isolation-levels-and-postgresql.html\n\n\n## Application\n\nIt's written in C++ and user pqxx library to connect to Postgres. It requires C++17 compiler (tested with gcc 10). It's been tested with PostgreSQL 12.3.\n\nIt has a number of parameters to change its behavior. You can run it with `--help` options to see them all.\n\n## Parameters\n\n`--threads` option tells the program how many threads it should run. By default, the application will open 10 connections to Postgres (it can be changed with `--connections`) and run threads to simulate the concurrent access to the database. At the end of a run, it prints the timings for each operation.\n\nTo gather benchmarks it's useful to run it with `--repetitions [n]` which will run every test `n` times and compute average timings.\n\n## Isolation levels\n\nThe transaction isolation level used in tests must be changed in the source code (`src/tasks.hpp` - `isolation` constant). Available options include: `read_committed`, `repeatable_read`, and `serializable`.\n\n## Compilation\n\nIt needs `pqxx` to talk to Postgres, make sure it's installed (https://github.com/jtv/libpqxx), I've tested it with version 7.07.\n\nYou also need a compiler supporting at least C++17, I've tested it with gcc 10.\n\nRun `make` in the main directory. That should give you a binary in `./bin/txn`.\n\n## Running tests\n\nYou need a Postgres database. You can spin one up with `docker-compose` by running\n\n```\ndocker-compose up\n```\n\nYou can quickly open shell with `./open_shell.sh`.\n\nA quick test can be run with `./bin/txn` which should run a test with 100 threads.\nYou can increase the number of threads with `--threads` and repeat tests with `--repetitions`. By default, it uses 10 connections to Postgres, this can be changed with `--connections`.\n\nE.g. to run 500 threads with 5 connections and repeat each test 3 times:\n\n```\n./bin/txn --threads 500 --repetitions 3 --connections 5 \n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flchsk%2Fpostgresql_transactions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flchsk%2Fpostgresql_transactions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flchsk%2Fpostgresql_transactions/lists"}