I have to query 3 tables which contains large number of data

I have to come up with report which displays

Employee Firstname, Lastname, Manager's FirstName, Manager's Lastname
and Organisation name.

Table Structure/Details:

1. Employee table: which contains employee information(First name,
lastname), Organisation id and manager's id.
2. Manager Table: Which contains firstname, lastname etc.
3. Organisation table: which contains organisation's name.

The process i follow is:
1. Fetch all the employees
   1.a for each employee get the manager id
       1.b  For the manager id get the manager's firstname and
lastname by querying the Manager table
    1.c for each employee get the organisation id
     1.d For each organisation id get the Organisation name by
querying the Organisation table.

When I try to fetch the records from 3 tables following the above
approach, I get deadlineexceedederror as my request could not complete
in 30 seconds time.

Please suggest a better way to do this. Also what should i use which
can improve performance and also get me the result in the 30 second
timeframe.

Reply via email to