I have a users
table, with following format :
users(id,name.....,settings)
settings
field is of type number
and contains a bitmask of settings.
I have to support(inter alia) queries like :
- find all users which have setting1, setting23, setting125
Today such a query looks like :
select * from users where bit_and(settings,2^1+2^23+2^125) = 2^1+2^23+2^125
Of course it is not a perfect implementation, but it already works in this way a lot of time.
The problem is that today we have 126 different settings and it is exactly the limit of oracle 11g
for bitwise operations. That means that we can't add new settings anymore.
I'm trying to find an alternative solution to this issue. The obvious way is instead of setting field, create table of mapping (user-->setting), like :
user_id | setting
128 | 1
128 | 23
128 | 125
But then the query like above will be like :
select *
from users u1 join settings s1 on u1.id = s1.user_id and s1.setting = 1
join settings s2 on u1.id = s2.user_id and s2.setting = 23
join settings s3 on u1.id = s3.user_id and s3.setting = 125
It doesn't look good...
So if someone can advise any solution/approach to this issue it will be very helpful...