title: How to prevent timeout in query?
body: <pre><code>SELECT C.CompanyName,
         B.BranchName, 
         E.EmployerName,
         FE.EmployeeUniqueID,
         pcr.EmployerUniqueID, 
         Case when FE.Status_id= 1 then 1 else 0 end IsUnPaid, 
         Case when re.EmployeeUniqueID IS NULL OR re.EmployeeUniqueID= '' then 0 else 1 end AS 'EmployeeRegistration',
         FE.IncomeFixedComponent,
         FE.IncomeVariableComponent, 
         Convert(varchar(11), Fe.PayStartDate, 106) as PayStartDate,
         Convert(varchar(11), Fe.PayEndDate, 106) as PayEndDate,
         S.StatusDescription, 
         FE.IsRejected, 
         FE.ID 'EdrID',   
         Convert(varchar(20), tr.TransactionDateTime, 113) as TransactionDateTime, 
         tr.BatchNo, 
         tr.IsDIFCreated, 
         Convert(varchar(20),tr.DIFFileCreationDateTime,113) as DiffDateTime
      From File_EdrEntries FE 
      JOIN PAFFiles pe ON pe.ID = FE.PAFFile_ID
      inner Join RegisteredEmployees RE
      ON RE.EmployeeUniqueID= FE.EmployeeUniqueID
      inner join File_PCREntries pcr on pe.ID=pcr.PAFFile_ID 
      JOIN Employers E ON E.EmployerID = pcr.EmployerUniqueID
      JOIN Branches B ON B.BranchID = E.Branch_ID 
      JOIN companies C ON C.COMPANYID = B.COMPANY_ID  
      JOIN Statuses S ON S.StatusID = FE.Status_ID
      JOIN Transactions tr on tr.EDRRecord_ID= fe.ID
      where  E.Branch_id=3
      AND FE.IsRejected=0 AND FE.Status_id= 3 and tr.BatchNo is not null
      AND Re.Employer_ID= re.Employer_ID;
  </code></pre>
  
  <p>THis query is supposed to return 10 million or more records and it usually causes timeout because of large no of records. So how can I improve its performance becauses I have done in where condition what I could.</p>