Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
muthu76
Starting Member
6 Posts |
Posted - 2009-09-24 : 05:05:55
|
| I am working in asp application.I have given data, start Date(1/1/1885) and End Date(1/1/2009) and press Submit button.The timeout error occur, when press submit button.The below query is executed, when I press submit button.Its return 25345 rows. How to avoid joins in the below query.SELECT d_case.c12_user_case_num, d_task.dt_original_open, d_task.dt_request_close, d_task.si_assignment_rec_type, d_task.c1_case_status, d_task.si_case_disposition, d_task.si_task_type, d_emp.c30_emp_last_nm, d_involved.c30_last_nm, d_involved.c15_first_nm, l_case_disp_status.c50_case_disp_status_descr, l_task_assign_type.c20_task_assign_descrFROM d_task INNER JOINd_case ON d_task.i_case_id = d_case.i_case_id INNER JOINd_involved ON d_task.i_case_id = d_involved.i_case_id INNER JOINl_case_disp_status ON d_task.si_case_disposition = l_case_disp_status.i_case_disp_status_id INNER JOINl_task_assign_type ON d_task.si_assignment_rec_type = l_task_assign_type.i_task_assign_type_id INNER JOINd_emp ON d_task.i_emp_sys_id = d_emp.i_emp_sys_idWHERE (d_task.si_task_type IN (860, 4230)) AND (d_task.c1_case_status = 'C') AND (d_task.dt_request_close >= '1/1/1885') AND (d_task.dt_request_close <= '1/2/2009') AND (d_case.c1_ref_bus_grp_id = 'I') AND (d_task.si_case_disposition IN (34, 35, 37, 47, 51, 66, 67, 108, 45, 116, 117)) AND (l_task_assign_type.i_task_assign_type_id = 2) AND (d_involved.si_involved_type_id = 60)ORDER BY d_emp.c30_emp_last_nmThanksMuthuYes |
|
|
AjarnMark
SQL Slashing Gunting Master
3246 Posts |
Posted - 2009-09-24 : 14:14:56
|
| Well, if you need fields from those tables, then you can't avoid doing a JOIN. But to make your results return more quickly, you can build indexes to help SQL Server do its work more efficiently. But which indexes you need should be based on an analysis of your whole system's needs, not just one query.One place to start is to run that SQL statement in a query window in SQL Server Management Studio and find out how long it is actually taking. Then start reading in Books Online or articles on this site about how to build indexes and some of the things to consider before building one.--------------------------------------------Brand yourself at EmeraldCityDomains.com |
 |
|
|
|
|
|
|
|