This is my query:
SELECT top 1 w.WONumber, * FROM TSP_TSR_Job t left join
wsm_WorkOrderSchedule w on w.tsrjobid = t.JobId WHERE t.JobID=325809
What I have tried:
DECLARE @i INT
SET @i=1
SELECT TOP (@i) ObjectType='Job',w.WONumber,*
FROM TSP_TSR_Job t
left HASH join wsm_WorkOrderSchedule w
on w.tsrjobid = t.JobId
WHERE t.JobID=325809
Execution plan:
Problem is that it's taking 0:0:1 sec for both queries.
2493073 rows in wsm_WorkOrderSchedule and 524444 in TSP_TSR_Job
brentozar.com/pastetheplan/?id=ByXUickKQ Execution plan
> SQL Server parse and compile time: CPU time = 0 ms, elapsed time =
> 0 ms.
>
> SQL Server Execution Times: CPU time = 0 ms, elapsed time = 0 ms.
> Warning: The join order has been enforced because a local join hint is
> used. SQL Server parse and compile time: CPU time = 5 ms, elapsed
> time = 5 ms.
>
> (1 row(s) affected) Table 'Workfile'. Scan count 0, logical reads 0,
> physical reads 0, read-ahead reads 0, lob logical reads 0, lob
> physical reads 0, lob read-ahead reads 0. Table 'Worktable'. Scan
> count 0, logical reads 0, physical reads 0, read-ahead reads 0, lob
> logical reads 0, lob physical reads 0, lob read-ahead reads 0. Table
> 'wsm_WorkOrderSchedule'. Scan count 1, logical reads 6, physical reads
> 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob
> read-ahead reads 0. Table 'TSP_TSR_Job'. Scan count 0, logical reads
> 6, physical reads 0, read-ahead reads 0, lob logical reads 0, lob
> physical reads 0, lob read-ahead reads 0.
>
> (1 row(s) affected)
>
> SQL Server Execution Times: CPU time = 16 ms, elapsed time = 11
> ms. SQL Server parse and compile time: CPU time = 0 ms, elapsed
> time = 1 ms.
>
> SQL Server Execution Times: CPU time = 1 ms, elapsed time = 1 ms.
