Efficiently determining the number of bits set in the contents of a VARBIT field - Mailing list pgsql-sql

From Allan Kamau
Subject Efficiently determining the number of bits set in the contents of a VARBIT field
Date
Msg-id 488B2404.7080106@sanbi.ac.za
Whole thread Raw
List pgsql-sql
Hi all,
Am looking for a fast and efficient way to count the number of bits set 
(to 1) in a VARBIT field. I am currently using 
"LENGTH(REGEXP_REPLACE(CAST(a.somefield_bit_code AS TEXT),'0','','g'))".

Allan.



pgsql-sql by date:

Previous
From: Volkan YAZICI
Date:
Subject: Re: Test if a table is present
Next
From: Giorgio Valoti
Date:
Subject: Re: Select default values