Does it make sense to use an index that will have a low cardinality?

An index can help even on low cardinality fields if: When one of possible values is very infrequent compared to the other values and you search for it. For instance, there are very few color blind women, so this query: SELECT * FROM color_blind_people WHERE gender=”F” would most probably benefit from an index on gender. … Read more

Is it possible to determine the number of elements of a c++ enum class?

Not directly, but you could use the following trick: enum class Example { A, B, C, D, E, Count }; Then the cardinality is available as static_cast<int>(Example::Count). Of course, this only works nicely if you let values of the enum be automatically assigned, starting from 0. If that’s not the case, you can manually assign … Read more