{"id":30876399,"url":"https://github.com/kmoppel/pgbench-tpcc-like","last_synced_at":"2026-02-12T13:39:44.972Z","repository":{"id":313428139,"uuid":"1009595509","full_name":"kmoppel/pgbench-tpcc-like","owner":"kmoppel","description":null,"archived":false,"fork":false,"pushed_at":"2025-09-05T23:48:15.000Z","size":70,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-06T01:19:43.453Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PLpgSQL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kmoppel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-06-27T11:43:00.000Z","updated_at":"2025-09-05T23:48:18.000Z","dependencies_parsed_at":"2025-09-06T01:19:45.216Z","dependency_job_id":"ebfd37de-e2f2-4679-83cf-3713a7bbd895","html_url":"https://github.com/kmoppel/pgbench-tpcc-like","commit_stats":null,"previous_names":["kmoppel/pgbench-tpcc-like"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/kmoppel/pgbench-tpcc-like","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmoppel%2Fpgbench-tpcc-like","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmoppel%2Fpgbench-tpcc-like/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmoppel%2Fpgbench-tpcc-like/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmoppel%2Fpgbench-tpcc-like/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kmoppel","download_url":"https://codeload.github.com/kmoppel/pgbench-tpcc-like/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmoppel%2Fpgbench-tpcc-like/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29367418,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-12T08:51:36.827Z","status":"ssl_error","status_checked_at":"2026-02-12T08:51:26.849Z","response_time":55,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2025-09-08T02:10:03.600Z","updated_at":"2026-02-12T13:39:44.967Z","avatar_url":"https://github.com/kmoppel.png","language":"PLpgSQL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pgbench-tpcc-like\n\nA more practical approach to the rather scientific TPC-C benchmark, to utilize Postgres better for the more daily\nbenchmarking and hardware validation purposes.\n\n**This is NOT an implementation of the official [TPC-C](https://www.tpc.org/tpc_documents_current_versions/current_specifications5.asp)\nworkload and should not be referred to as one!**\n\n## The why\n\nFor ages Postgres DBA-s have used the `pgbench` for quick hardware / config validation...but sadly all default\npgbench transaction modes doing writing (*tpcb-like* and *simple-update*) are abnormally write-heavy and test\nbasically only the *key-value* access scenario...which mostly is not very real-life at all for a RDBMS.\n\nTPC-C is already more real-life...but sadly the common benchmarking frameworks supporting it are often:\n* Overly complex / generic (to support other DB engines as well)\n* GUI-controlled\n* Bring in a bunch of dependencies\n* Customizations require knowing some less-known scripting language like Tcl or Lua, or actual programming in Java etc,\n  which can be a mood killer for sure for a quick test\n* Make it hard to estimate the output DB size\n* Don't allow to dynamically increase of the dataset / warehouse count\n\n# Implementation details\n\n* No external benchmarking toolkits required\n* Uses a mix of SQL, PL/pgSQL and pgbench scripting - meaning easy modifications for anyone \"friendly\" with Postgres\n* Data population designed to be \"additive\" and parallel\n* Fast dataset population, a la generates_series()\n* Tables not duplicated \"per warehouse\"\n* Limited randomness on \"warehouse\" selection - only the last 20% of warehouses are active (by default)\n* 1 warehouse = 1x 01_init_data.pgbench execution = ~100MiB of data\n* A few secondary indexes have been added to be more realistic (TPC-C spec only has PK/UQ-s)\n* Weights can easily be adjusted to steer the testing towards, say, more reads\n* Supports very long runtimes with more than 2B+ (64-bit IDs) orders \n\n# Running\n\n```\ngit clone https://github.com/kmoppel/pgbench-tpcc-like.git \u0026\u0026 cd pgbench-tpcc-like \n\ncreatedb tpcc\n\npsql -f 00_schema.sql tpcc \n\n# Init dataset with a size of ~40GB. 4*100=400 \"warehouses\" (1 WH ~ 110MB of data and indexes)\npgbench -n -f 01_init_data.pgbench -c 4 -t 100 tpcc \n\n# Ensure stats collected\nvacuumdb --analyze -j 4 --schema public tpcc\n\n# Ensure pg_stat_statements, reset stats\npsql -c \"create extension if not exists pg_stat_statements\" \\\n  -c \"select pg_stat_reset(), pg_stat_reset_shared(), pg_stat_statements_reset()\" tpcc\n\n# Test for 30min with 32 clients\n# PS Warehouse count / scale needs to be much higher than client count, not to get throttled by locking!\n# PS2 Need to explictly set ACTIVE_WHS! Here only 30% of warehouses are being actively used\npgbench -n -c 32 -T 1800 -P 300 -D ACTIVE_WHS=0.3 \\\n  -f new_order.pgbench@45 -f payment_transaction.pgbench@43 -f order_status.pgbench@4 \\\n  -f delivery_transaction.pgbench@4 -f stock_check.pgbench@4 tpcc\n\n# Analyze results / stats ...\n```\n\n# Contributing\n\nFeedback and PR-s very much appreciated!\n\n# TODO\n\n* Investigate if can support running in `--protocol=prepared` mode as well.\n* Add a Dockerfile + auto build \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkmoppel%2Fpgbench-tpcc-like","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkmoppel%2Fpgbench-tpcc-like","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkmoppel%2Fpgbench-tpcc-like/lists"}