Hi guys,
I have the query as below
the column all coming from 'VIEW' as you guys could see start with 'v_' which takes around 4 mins.
If I change the query using table (remove the leading v_ ) it only takes around 30 seconds.
we need the view because it contains conversion from table column.
I was wondering what should I do to reduce the difference between view and table for above query.
Thanks for the input
I have the query as below
Code:
SELECT queen.exp_std_rec_type, convert(varchar(12),dc.reporting_date,103) as reporting_date, replace(replace(replace(replace(dc.description, '(FULL) - ',''),convert(varchar(12), dc.reporting_date, 103),''),
convert(varchar,dc.reporting_date,107),''), '['+ rtrim(cast(dc.cid as char(4))) + '] - ','') as report_type,
queen.exp_std_rec_id, b.is_trading_book, 'OT' AS TABLETYPE, queen.supervisory_category,
queen.exp_key, queen.entity
FROM v_t_queen_airb_otc_derivative_cb AS queen
INNER JOIN v_t_bisb2110 AS b ON queen.exp_std_rec_id = b.std_rec_id and b.std_rec_type = queen.exp_std_rec_type INNER JOIN
v_r_calc_lot AS cl ON queen.lid = cl.lid INNER JOIN
v_r_calc_definition AS run ON queen.cid = run.cid INNER JOIN
v_d_calc AS dc ON dc.cid = run.cid INNER JOIN
v_d_exp_class AS dec ON queen.exp_class = dec.exp_class LEFT OUTER JOIN
v_d_customer AS dcu ON dcu.customer_nr = queen.customer_nr AND dcu.is_latest = 1 LEFT OUTER JOIN (select distinct supervisory_category, ul_rw, el_rw
from v_r_supervisory_slotting_relation_cb
inner join v_d_calc cc2 on 1 = 1
where start_validity_date <= cc2.reporting_date
and end_validity_date >= cc2.reporting_date) as sl
on isnull(queen.supervisory_category,0) = isnull(sl.supervisory_category,0) LEFT OUTER JOIN
v_d_entity AS de ON de.entity = queen.entity
WHERE (dec.is_latest = 1) AND (queen.report_type NOT LIKE '%No com%') AND queen.exp_std_rec_type = 'retail'
the column all coming from 'VIEW' as you guys could see start with 'v_' which takes around 4 mins.
If I change the query using table (remove the leading v_ ) it only takes around 30 seconds.
we need the view because it contains conversion from table column.
I was wondering what should I do to reduce the difference between view and table for above query.
Thanks for the input