enter image description here this is my exection plan of my query
i want to optimize the query my table structure is given below
SELECT DISTINCT
c.transaction_id,
c.property_id,
c.ward_id,
w.ward_no,
c.holding_no,
c.collector_id,
t.payment_mode,
t.date,
t.payment_ref,
t.dd_date,
t.bank_name,
t.branch,
t.amount,
t.discount,
t.transaction_no,
t.pos_no,
t.sms_status,
t.remarks,
ch.id AS cheque_id,
ch.check_no,
ch.bank,
ch.check_date,
ch.amount AS chk_amount,
ch.reconcilation_date,
ch.chk_status,
ch.status AS isValid,
ch.bank_reconcilation_date,
t.penalty
FROM
dbo.tbl_collection_master AS c
INNER JOIN dbo.tbl_transaction_master AS t
ON c.transaction_id = t.id
LEFT OUTER JOIN dbo.tbl_cheque_details AS ch
ON t.id = ch.transaction_id
left join tbl_Ward_Master w
on c.ward_id = w.id
The following recommendations will help you in your SQL tuning process.
You'll find 3 sections below:
ALTER TABLE `tbl_Ward_Master` ADD INDEX `tbl_master_idx_id` (`id`);
ALTER TABLE `tbl_cheque_details` ADD INDEX `tbl_details_idx_transaction_id` (`transaction_id`);
ALTER TABLE `tbl_transaction_master` ADD INDEX `tbl_master_idx_id` (`id`);
SELECT
DISTINCT c.transaction_id,
c.property_id,
c.ward_id,
w.ward_no,
c.holding_no,
c.collector_id,
t.payment_mode,
t.date,
t.payment_ref,
t.dd_date,
t.bank_name,
t.branch,
t.amount,
t.discount,
t.transaction_no,
t.pos_no,
t.sms_status,
t.remarks,
ch.id AS cheque_id,
ch.check_no,
ch.bank,
ch.check_date,
ch.amount AS chk_amount,
ch.reconcilation_date,
ch.chk_status,
ch.status AS isValid,
ch.bank_reconcilation_date,
t.penalty
FROM
dbo.tbl_collection_master AS c
INNER JOIN
dbo.tbl_transaction_master AS t
ON c.transaction_id = t.id
LEFT OUTER JOIN
dbo.tbl_cheque_details AS ch
ON t.id = ch.transaction_id
LEFT JOIN
tbl_Ward_Master w
ON c.ward_id = w.id