↑↓ select ↵ open ⌫ change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Functions / Binary String Functions And Operators

Returns the number of bits set in the binary string (also known as “popcount”).

Reading PG 18current·documented in 7 of 27 versions, 14 to 20

Signatures & examples

bit_count ( bytes bytea ) → bigint
Returns the number of bits set in the binary string (also known as “popcount”).
bit_count('\x1234567890'::bytea) → 15
bit_count ( bit ) → bigint
Returns the number of bits set in the bit string (also known as “popcount”).
bit_count(B'10111') → 4
Version history 1
  1. 13 → 14 added

Definition snapshot: 2026-09-14T13:14:25.684213+00:00@99e6866c · English manual source