{"id":14384394,"url":"https://github.com/porsager/postgres-benchmarks","last_synced_at":"2025-04-12T00:24:35.618Z","repository":{"id":51651081,"uuid":"231633007","full_name":"porsager/postgres-benchmarks","owner":"porsager","description":"A set of benchmarks focusing on the performance of Postgres client libraries for Node.js","archived":false,"fork":false,"pushed_at":"2024-03-28T09:49:18.000Z","size":1191,"stargazers_count":89,"open_issues_count":6,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T20:12:30.863Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/porsager.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-01-03T17:20:38.000Z","updated_at":"2025-03-21T01:33:37.000Z","dependencies_parsed_at":"2024-11-25T10:45:43.299Z","dependency_job_id":"351464ee-1c20-41a5-ae8e-7d9e0dff2609","html_url":"https://github.com/porsager/postgres-benchmarks","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/porsager%2Fpostgres-benchmarks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/porsager%2Fpostgres-benchmarks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/porsager%2Fpostgres-benchmarks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/porsager%2Fpostgres-benchmarks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/porsager","download_url":"https://codeload.github.com/porsager/postgres-benchmarks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248498702,"owners_count":21114177,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2024-08-28T18:01:21.287Z","updated_at":"2025-04-12T00:24:35.594Z","avatar_url":"https://github.com/porsager.png","language":"JavaScript","readme":"# Postgres Library Benchmarks for Node.js\n\nThis is a set of benchmarks focusing on the performance of Postgres client libraries for Node.js. The benchmarks are primarily direct selects of values to measure the input-output performance and not the Performance of postgres data fetching.\n\n\u003e NB. In daily usage it is very likely that this difference doesn't matter as much since the time spent by the client library is negligable compared to the query time itself.\n\nCurrently benchmarked libraries are\n\n- [Postgres.js](https://github.com/porsager/postgres)\n- [pg-promise](https://github.com/vitaly-t/pg-promise)\n- [pg](https://github.com/brianc/node-postgres)\n- [pg-native](https://github.com/brianc/node-pg-native)\n- [slonik](https://github.com/gajus/slonik)\n\n\n## Results\n\nThese are the results from running the benchmarks on a Macbook Pro 2,9 GHz Quad-Core Intel Core i7 with a default Postgres 12.6 installation and Node 12.20.1.\nThe time is the average of 5 rounds, running the queries 10,000 times after some warmup rounds.\n\nclient     |         select |     select_arg |    select_args |   select_where\n:--------- | -------------: | -------------: | -------------: | -------------:\n[Postgres.js](https://github.com/porsager/postgres)   |  0.100s (4.8x) |  0.105s (7.4x) |  0.231s (4.3x) |  0.233s (5.1x)\n[pg-promise](https://github.com/vitaly-t/pg-promise) |  0.360s (1.3x) |  0.427s (1.8x) |  0.662s (1.5x) |  0.801s (1.5x)\n[pg-promise-native](https://github.com/vitaly-t/pg-promise) |  0.371s (1.3x) |  0.435s (1.8x) |  0.673s (1.5x) |  0.807s (1.5x)\n[pg](https://github.com/brianc/node-postgres)         |  0.322s (1.5x) |  0.611s (1.3x) |  0.815s (1.2x) |  1.057s (1.1x)\n[pg-native](https://github.com/brianc/node-pg-native)  |  0.479s (1.0x) |  0.551s (1.4x) |  0.885s (1.1x) |  1.183s (1.0x)\n[slonik](https://github.com/gajus/slonik)     |  0.453s (1.1x) |  0.773s (1.0x) |  0.992s (1.0x) |  1.108s (1.1x)\n\n![results chart](results.png)\n\u003e lower is better\n\n## Query descriptions:\n\n#### select\n\n```sql\nselect 1 as x\n```\n\n#### select_arg\n\n```sql\nselect $1 as x\n\n-- $1 is just 1\n```\n\n#### select_args\n```sql\nselect\n  $1 as int,\n  $2 as string,\n  $3 as timestamp,\n  $4 as null,\n  $5 as boolean,\n  $6 as bytea,\n  $7 as json\n\n--$1 = 1337\n--$2 = 'wat'\n--$3 = new Date()\n--$4 = null\n--$5 = false\n--$6 = Buffer.from('awesome')\n--$7 = \"[{ \"some\": \"json\" }, { \"array\": \"object\" }]\"\n```\n\n#### select_where\n\n```sql\nselect * from pg_catalog.pg_type where typname = $1\n\n--$1 = 'bool'\n```\n\n\n#### Running the benchmark\n\nEnsure you have a PostgreSQL server running. You can add connection details using environment vars PGDATABASE, PGUSER etc.\n\n```bash\nnpm install\nnpm start\n```\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fporsager%2Fpostgres-benchmarks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fporsager%2Fpostgres-benchmarks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fporsager%2Fpostgres-benchmarks/lists"}