bitmap_union function
Description
This is an aggregate function used to calculate the union of bitmaps after group. It is often used in scenarios such as PV and UV calculation.
Syntax:
BITMAP BITMAP_UNION(BITMAP value)
You enter a set of bitmap values; the function calculates the union of this set of bitmap values and returns a result.
Example
mysql> select page_id, bitmap_union(user_id) from table group by page_id;
Combined with the bitmap_count function, the PV data of the web page can be obtained
mysql> select page_id, bitmap_count(bitmap_union(user_id)) from table group by page_id;
When the user_id field is int, the above query semantics is equivalent to
mysql> select page_id, count(distinct user_id) from table group by page_id;
Keywords
BITMAP_UNION, BITMAP