Skip to content

Searching a multiplexed database column

August 4, 2011

Multiplexing columns is an optimization used in some database  schema. The idea is to store multiple integers or boolean values  in a single integer column. The read and write operations are done using bit wise operators. For example we can store several flags in a single integer column, the first flag value is 1, the second 2, the third value is 4, etc.

Scoped search is able to expose multiplexed filed by specifying the offset and word size. In the common case of multiplexing booleans, the word size is 1.

scoped_search :on => :counters, :offset => 0 , :word_size => 6, :rename => :applied
scoped_search :on => :counters, :offset => 1 , :word_size => 6, :rename => :skipped

The search syntax will expose the multiplexed column as multiple columns.


From → Design, Developers

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: