{"id":23062551,"url":"https://github.com/eschmar/postgresql-popcount","last_synced_at":"2025-08-15T08:33:43.836Z","repository":{"id":73758147,"uuid":"133954435","full_name":"eschmar/postgresql-popcount","owner":"eschmar","description":"PostgreSQL Extension introducing popcount[|32|64|Asm|Asm64|256](bit(n)).","archived":false,"fork":false,"pushed_at":"2023-04-22T15:28:50.000Z","size":212,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-24T07:02:17.282Z","etag":null,"topics":["bitcount","extension","hamming-weight","look-up-table","popcnt","popcount","postgresql"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eschmar.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}},"created_at":"2018-05-18T12:56:31.000Z","updated_at":"2023-03-17T12:11:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"465cc9ca-50e9-4ce3-a5d5-d3026eb9838a","html_url":"https://github.com/eschmar/postgresql-popcount","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/eschmar/postgresql-popcount","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eschmar%2Fpostgresql-popcount","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eschmar%2Fpostgresql-popcount/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eschmar%2Fpostgresql-popcount/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eschmar%2Fpostgresql-popcount/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eschmar","download_url":"https://codeload.github.com/eschmar/postgresql-popcount/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eschmar%2Fpostgresql-popcount/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270544948,"owners_count":24604451,"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","status":"online","status_checked_at":"2025-08-15T02:00:12.559Z","response_time":110,"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":["bitcount","extension","hamming-weight","look-up-table","popcnt","popcount","postgresql"],"created_at":"2024-12-16T03:27:24.037Z","updated_at":"2025-08-15T08:33:43.828Z","avatar_url":"https://github.com/eschmar.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"**Note:** PostgreSQL version 14 introduced their own [`bit_count`](https://www.postgresql.org/docs/14/functions-bitstring.html). You may find [their implementation here](https://github.com/postgres/postgres/blob/master/src/port/pg_bitutils.c) (or [here](https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/port/pg_bitutils.c;hb=HEAD)) for comparison. It is therefore recommended to only use this repository for postgres versions \u003c14. More information in [this blog post](https://eschmann.dev/2023/04/revisiting-popcount-on-postgres-14).\n\n# PostgreSQL population count function for data type bit(n).\nProvides `popcount`, `popcount32`, `popcount64`, `popcountAsm`, `popcountAsm64` and `popcount256` functions to PostgreSQL. The extension was elected to provide all algorithms to enable a conscious choice on runtime. Statistical benchmark data suggests that `popcountAsm64` should be chosen in most cases.\n\n## Usage\nThe extension is [available on PGXN](https://pgxn.org/dist/popcount/).\n\n```sh\npgxn install popcount\n```\n\nIf you want to compile it yourself, `pg_config` is required.\n\n```sh\nmake install\nmake installcheck\n```\n\n## Benchmarks 2018\n\u003cimg src=\"https://github.com/eschmar/postgresql-popcount/raw/master/img/graph.png\" alt=\"Benchmarks 2018\" style=\"max-width:100%;\"\u003e\n\nThe test bench was running an Intel(R) Xeon(R) Platinum 8168 CPU @ 2.70GHz on Ubuntu 18.04 and PostgreSQL 10.3.\n\n## Benchmarks 2023\nMore information in [this blog post](https://eschmann.dev/2023/04/revisiting-popcount-on-postgres-14).\n\n\u003cimg src=\"https://github.com/eschmar/postgresql-popcount/raw/master/img/graph-2023.png\" alt=\"Benchmarks 2023\" style=\"max-width:100%;\"\u003e\n\nThe test bench was running an Intel(R) Xeon(R) Platinum 8358 CPU @ 2.60GHz on Ubuntu 22.04 and PostgreSQL 14.7. It can be reproduced the following way.\n\n```sh\n./helper/generate_db_postgres.sh -d 500000 -a \"2048 4096 8192\"\n./benchmark/postgres.sh -s popcountAsm64 -t 50 -d 500000 -a \"2048 4096 8192\"\n```\n\noption | values | comment\n--- | --- | ---\n-s | `popcount`, `popcount32`, `popcount64`, `popcountAsm`, `popcountAsm64`, `popcount256` | 8bit lookup table, 32bit hamming weight, 64bit hamming weight, 32 bit intrinsic function, 64 bit intrinsic function, unrolled assembly instruction.\n-t | *integer* | Number of trials.\n-d | *integer* | Number of rows in domain.\n-a | *integer* | Bit alignments to test.\n--units | - | Whether time units should be printed or not.\n\n## Setup\nSetup instructions on Ubuntu 22.04 LTS for convenience.\n\n```sh\n# install dependencies\nsudo apt update\nsudo apt install build-essential postgresql postgresql-contrib libpq-dev postgresql-server-dev-14 make\nsudo systemctl start postgresql.service\n\n# install extension...\nsudo -i -u postgres\ngit clone https://github.com/eschmar/postgresql-popcount.git\ncd postgresql-popcount\nmake install\nmake installcheck\n\n# .. and enable it\npsql\nCREATE EXTENSION popcount;\n\\q\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feschmar%2Fpostgresql-popcount","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feschmar%2Fpostgresql-popcount","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feschmar%2Fpostgresql-popcount/lists"}