I was just working on a web application and find that the most the mysql tables have fields, like, is_live, can_do, required, published (and many more) having field type TINYINT, and takes either 0 or 1 only. I was just wondering if I need to create indexes on these columns as scripts are using joins which include these columns as well. So questions are :
Should I add indexes to these columns as well?
Should I change the type to anything else?
Please see this question is more to do with understanding the concept rather than solving a problem.
Thanks.
My database guru says, “never add any index if you do not know the query”. In your case, looks like you do know the query. So yes, we can think about index.
In case you have a data warehouse type of system, create bitmap index. otherwise do not create any index. B-tree indices are bad on such a small cardinality columns.