In case you have your own slow SQL query, you can optimize it automatically here.
For the query above, the following recommendations will be helpful as part of the SQL tuning process.
You'll find 3 sections below:
SELECT
txh.clid AS clid,
txh.id AS hlid,
holdinNo,
holding,
ClientID AS cliendID,
ClientName,
itm.itemID,
itm.Item,
itm.rate,
(SELECT
TOP 1 asset
FROM
tx_asset
WHERE
tx_asset.hlid = txh.id
ORDER BY
txh.id DESC) AS asset
FROM
tx_holding AS txh
INNER JOIN
tx_set_bill_holding AS itm
ON txh.id = itm.hlid
AND itm.status = 1
WHERE
txh.id IN (
SELECT
hlid
FROM
tx_asset
WHERE
asset IS NOT NULL
AND asset != 0
)
AND txh.id NOT IN (
SELECT
hlid
FROM
tx_bill_pay
WHERE
YEAR(tx_bill_pay.date_month) = YEAR(@tdate)
AND hlid IS NOT NULL
)
AND txh.clid IN (
SELECT
tbl_client.id
FROM
tbl_client
WHERE
tbl_client.client_type = 'Non-Govt.'
)
AND itm.type = 'Non-Govt.'
AND txh.roadno = @roadno