Get all the users being a manager

Hey guys,

I have a small issue today. I have a database containing thousands of users and some are the manager of others. To link them, I referenced the manager's id into its subordinates' column named 'ManagerId'.

Since some of my SQL queries were quite slow, I reproduced a few months ago my User table into an index (ElasticSearch) and today, for a new feature of my solution, I would like to only retrieve the managers.

At the beginning, I simply added a 'IsManager' field into the User index (ElasticSearch) and filled it by checking if the column 'ManagerId' of the table User (SQL) is containing the user being currently indexed's id (through a LINQ query - 'Any').

As expected my program is taking way more time to index all the users compared to before and I am wondering if the solution I implemented was the good one... Here is a summary of everything I said:

  • SQL: User table containing a ManagerId column
  • ElasticSearch: User index containing most of the User table's properties (ManagerId is included !)
  • I would like to only retrieve the managers by querying ElasticSearch

I am posting here to know if there is another solution to get the wanted data without the IsManager and hopefully to win back the indexation time that I just lost.

Hoping I was clear enough into my explanations and wishing you a great weekend !
Best regards,

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.