SQL query optimization in SQL Server -
in sql server, query execution plan, 2 operations (parallelism , hash match) getting 30 % , 45 % of total cost.
what mean of parallelism , hash match?
for parallelism, have checked on link number of parallelism can effect performance of query, how check number of degree of parallelism of server?
how reduce cost? have no idea how can reduce cost.
my query returning 42 million rows , joining 5 tables; no where
conditions, no group by
, order by
clauses.
i have non-clustered indexes on join columns.
my query is:
select [inv].sku [inv_sku], [inv].location_id [inv_location_id], [inv].date [inv_balance_date], [inv].cost inv_cost, [item].item_id, [item].item_name, [spitem].itemnumber sp_itemid, [spitem].name, [spitem_dept].[skey], [spitem_dept].[dept_name], [time].[date] [cal_date], [time].[cal_name] [cal_name], [time].[year_name] [year_name], [time].[year_num] [year_num], [time].[year_start_dt] [year_start_dt], isnul(convert(int, convert(varchar, [time].[week_end_dt], 112)), 0) [week_end_dt_skey], case when [item].department null (case when [spitem_dept].spitem_dept_name = 'unspecified' 0 else [spitem_dept].spitem_dept_name end) else [item].department end [departmentnum], case when [item].[department_description] null [spitem_dept].[description] else [item].[department_description] end [item_department_desc], [location].location_name, [location].country, [location].currency, [currency].base_currency [dbo].[table1] [inv] left join dbo.table2 [item] on ([inv].sku = [item].sku ) left join dbo.table3 [location] on ([inv].location_id = [location].location_id) inner join dbo.table4 [time] on ([inv].date = [time].date) left join dbo.table5 [spitem] on ([inv].sku = spitem.name) left join [dbo].[table6] [spitem_dept] on ([spitem].[ws_kpi_item_merchandise_department_skey] = [spitem_dept].[skey]) left join [dbo].[table7] [currency] on ([inv].date between [currency].begin_dt , [currency].end_dt , [location].currency= [currency].local_currency)
and have non-clustered index on joining columns too.
please suggest possible solutions, can try.
i newbie sql server query optimization.
the number of rows huge , me main problem don't have conditions, if have indexes not predicate bad scenario. number of degree parallelism set dba, indicates threshold operator work in parallel or serial way.
https://technet.microsoft.com/es-es/library/ms181007%28v=sql.105%29.aspx?f=255&mspperror=-2147217396
i recommend review free book of grant fritchey execution plan: https://www.red-gate.com/library/sql-server-execution-plans-2nd-edition
however, pieces of advises are:
1) adding filter in query (where)
2) review indexes strategy
Comments
Post a Comment