Slow two-table query in SQL Server
问题 The application I work on generates an SQL query somewhat like this: Select VISIT_VIEW.VISIT_ID, VISIT_VIEW.PATIENT_ID, VISIT_VIEW.MRN_ID, VISIT_VIEW.BILL_NO, INSURANCE.INS_PAYOR' FROM 'VISIT_VIEW LEFT JOIN INSURANCE ON VISIT_VIEW.visit_id = INSURANCE._fk_visit ' WHERE 'VISIT_VIEW.VISIT_ID IN (1002, 1003, 1005, 1006, 1007, 1008, 1010, 1011, <...>, 1193, 1194, 1195, 1196, 1197, 1198, 1199)' The <...> represents a long list of ids. The size of the list depends on the results of a previous query