I am building an application where if an admin logs in, he can see the entire Employee Details from all shores. Currently, I am using a recursive function to fetch it from DB which is making the application too slow. How to use MySQL hierarchy query to fetch all the direct and indirect employees under any admin employee and show the result in one go. Currently, more than 3k employee records are kept. Now for instance, if 1230 who is an admin logs in, he can see entire org employee ID including his direct reportees and indirect reportees as well.
My table name is: Employee_Table
Employee_ID Manager_ID
123 1230
124 1230
125 1230
456 123
457 123
458 123
789 124
780 124
781 124
4512 125
4513 125
4514 125
..... and many more like this. (3k records). I referred to the other solutions in same type but they do seems to work in my case since the records are much higher.