Let's say I need to query\delete employees by
- their department
- their department & name
The first option would be to use a single ordered composite index and do partial key look ups:
boost::multi_index::ordered_non_unique<
boost::multi_index::tag<ByDepartmentAndName>,
boost::multi_index::composite_key<
boost::multi_index::member<
Employee, int, &Employee::department>,
boost::multi_index::member<
Employee, std::string, &Employee::name>>>
Or I can define 2 separate hash indices:
boost::multi_index::hashed_non_unique<
boost::multi_index::tag<ByDepartmentAndName>,
boost::multi_index::composite_key<
boost::multi_index::member<
Employee, int, &Employee::department>,
boost::multi_index::member<
Employee, std::string, &Employee::name>>>>,
boost::multi_index::hashed_non_unique<
boost::multi_index::tag<ByDepartment>,
boost::multi_index::member<
Employee, int, &Employee::department>>
I would assume the first option is more space efficient since it is a single index. But it is probably slower due to O(log^N) search vs O(1) search of hash index.
What would be the right option here?