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:
CREATE INDEX jobs_idx_viewable_timestamp ON jobs (viewable,timestamp);
CREATE INDEX processes_idx_group_id ON processes (group,id);
CREATE INDEX status_idx_id_name ON status (id,name);
CREATE INDEX tasks_idx_id_processid ON tasks (id,processid);
SELECT
DISTINCT TOP 500 j.correlationid,
j.timestamp
FROM
jobs AS j
WHERE
(
j.viewable = 1
AND 1 = 1
AND 1 = 1
)
AND (
EXISTS (
SELECT
1
FROM
status AS s
INNER JOIN
tasks AS t
INNER JOIN
processes AS p
WHERE
(
(
(
(
j.statusid = s.id
)
AND (
s.name IN (
'Dead', 'Process Complete'
)
)
)
AND (
j.taskid = t.id
)
)
AND (
t.processid = p.id
)
)
AND (
p.[group] = 'SapDocument'
)
)
)
ORDER BY
j.timestamp DESC