FlagShihTzu: Rails plugin to store boolean attributes in a single bit field column
The FlagShihTzu plugin, developed by the Rails team at XING, lets you add new boolean attributes to your models without db migrations.
Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!
The FlagShihTzu plugin, developed by the Rails team at XING, lets you add new boolean attributes to your models without db migrations.
Comments
Add boolean variables without the need to add and run db migrations? Seems like an odd reason to me… you need to restart the server… etc in any case if you make code changes. I suppose it will save you 17 seconds.
This is so not OOP…
@mike: Depending on the RDBMS you use, it can really help on tables that already have millions of rows, where ALTER TABLE may take a lot of time.
@madbang: The code or the idea? :)
Thanks for the feedback!
Not a chance that mysql can actually use an index on flags to get the result of a query like:
select * where (flags&4 = 1)
@du: MySQL can use an index on the flags column for the given query. That is one of the advantages of the approach, to only require a single index.
@boosty I think @du is correct. MySQL doesn’t support bitmap indexes and thus I believe a query like select * where (flags&4 = 1) would always have to do a full table scan.
http://forum.percona.com/index.php/m/2683/
@ejunker: You are right, the where condition cannot use the index as expected (I was mixing up my information, using a covering index for my queries).
There is already a patch for flag_shih_tzu coming up to rewrite the query to use IN() instead of boolean operators, which can then use the index: http://github.com/tilsammans/flag_shih_tzu
Post a comment