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:
ALTER TABLE `AnotherTable` ADD INDEX `anothertable_idx_subjectid` (`SubjectID`);
ALTER TABLE `SomeTable` ADD INDEX `sometable_idx_subjectid` (`SubjectID`);
ALTER TABLE `YetAnotherTable` ADD INDEX `yetanothertable_idx_subjectversionid` (`SubjectVersionID`);
SELECT
'SomeTable' AS tname,
COUNT(*) AS ttlRecords
FROM
SomeTable
WHERE
SomeTable.SubjectID = @SubjectID
UNION
SELECT
'AnotherTable' AS tname,
COUNT(*) AS ttlRecords
FROM
AnotherTable
WHERE
AnotherTable.SubjectID = @SubjectID
UNION
SELECT
'YetAnotherTable' AS tname,
COUNT(*) AS ttlRecords
FROM
YetAnotherTable
WHERE
YetAnotherTable.SubjectVersionID = @SubjectVersionID