How to use MySQL bitmap index to solve the problem of user portrait
This article is about how to use MySQL bitmap index to solve the problem of user portraits. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Each bigint type includes 60 recorded bit information.
But bit 0 represents the bit of the 60th record
Bits 1 to 59 represent the bit information of the first to 59 records.
In this way, the bit information recorded is not continuous.
When using it, you have to move the rightmost bit to the leftmost, which is difficult to understand and has a loss of performance.
After the improvement of Wang Gong
Using the following sql replacement, the saved bit information is continuous.
SELECT CEIL (id / 60) G60, CEIL (id / 1200) g1200, age grouped, COUNT (*) total, BIT_OR (1