I have written some sql (below) however it is running so slowly and was wondering if there was any advice / examples / suggestions how I could speed this up. It may be glaringly obvious to some but not me. Also the lines are duplicated.
Any help would be great
SELECT
a.account,
a.amount,
a.apar_id,
h.apar_name,
g.description as 'supplier description',
d.description as 'supplier catagory',
a.description as 'expense description',
a.dim_1 as 'cost centre',
d1.description,a.dim_7 as 'legal ent',
a.period,a.trans_date,a.voucher_no
FROM agltransact a
LEFT JOIN asuheader h ON a.apar_id = h.apar_id AND a.client=h.client
LEFT JOIN acrtrees t ON t.cat_1=a.apar_id AND t.att_agrid='61' AND t.client=a.client
LEFT JOIN acrtrees t1 ON t1.dim_b=a.dim_7 AND t1.att_agrid='47' AND t1.client=a.client
LEFT JOIN agldescription d1 ON d1.dim_value=t1.dim_c AND d1.attribute_id='71' AND d1.client=a.client
LEFT JOIN agldescription d ON d.dim_value=t.dim_a AND d.attribute_id='2661' AND d.client=a.client
LEFT JOIN asugroup g ON g.apar_gr_id=h.apar_gr_id AND g.client=a.client
WHERE
a.client='CL'
AND period >='201307' and period <='201406'
AND (t.dim_a='1030' OR a.account IN ('43050','43100'))
AND a.account!='A5200'