sql - How should I index my table -
sql - How should I index my table -
i have query :
select distinct be.sk_loan_id, be.deal_id, val.amount rest_balance, lo.value_date effective_start_date, lo.maturity_date effective_maturity_date, lo.currency_id currency, '0' process_status, sub.char_cust_element1 installment_date, sub.char_cust_element2 installment_type, sub.char_cust_element5 rest_balance_freq, lo.repayment_principal_freq, lo.next_principal_sch_date, lo.next_interest_sch_date, lo.repayment_interest_freq, lo.interest_basis, lo.interest_rate, lo.base_rate, s.amount principal_amount, isnull(prevval.prev_amount_change, 0) prev_amount_change t_trn_loan_business_event inner bring together t_trn_loan lo on be.sk_loan_id = lo.sk_id inner bring together t_trn_loan_valuation val on lo.sk_id = val.sk_loan_id inner bring together t_deal_subtype sub on lo.deal_subtype = sub.deal_subtype inner bring together t_trn_loan_schedule s on be.deal_id = s.deal_id , s.amount_type <> 'int' , '2012-1-1' between s.start_validity_date , s.schedule_end_date left bring together (select sk_loan_id, sum(case when v.sk_loan_valuation_type = 24 amount else -amount end) prev_amount_change t_trn_loan_valuation v v.sk_loan_valuation_type in (24, 27) , v.sk_time_id < 4384 grouping sk_loan_id) prevval on be.sk_loan_id = prevval.sk_loan_id be.sk_business_event_type_id in (17, 18, 7, 3, 8, 14, 19, 20) , val.sk_loan_valuation_type = 25 , be.sk_time_id = 4384 , process_flag1 = '0'
i want improve performance of query. columns should set in index have best performance? however, insert big amount of info in t_trn_loan_business_event
, t_trn_loan valuation
.
for example, in table t_trn_loan_valuation
, right have 3 indexes:
sk_loan_id
(clustered) sk_loan_valuation_type
sk_time id
should utilize non-clustered index column sk_loan_id
? or should set them in 1 index (sk_loan_id, sk_valuation_type, sk_time_id
)?
if so, should create clustered or non-clustered?
thanks,
sql sql-server performance sql-server-2008 indexing
Comments
Post a Comment