• Hi,

    Created the main tables with 91.000 rows and the reference tables with 10.000.000 rows.

    Same data on both pair of tables.

    Ran the queries and the time and IO individually were the same.

    But when I ran together the queries:

    PRINT '---------------------------------------------'

    SELECT s.col1fk from stable_c s inner join ptable_cc p on s.col1fk = p.col1 where p.col1 like 'RAB%'

    PRINT '---------------------------------------------'

    SELECT s.col1fk from stable_vc s inner join ptable_vc p on s.col1fk = p.col1 where p.col1 like 'RAB%'

    PRINT '---------------------------------------------'

    sometimes I got:

    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.

    (114 row(s) affected)

    Table 'stable_c'. Scan count 1, logical reads 3, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

    Table 'ptable_cc'. Scan count 1, logical reads 3, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

    SQL Server Execution Times:

    CPU time = 0 ms, elapsed time = 0 ms.

    ---------------------------------------------

    SQL Server Execution Times:

    CPU time = 0 ms, elapsed time = 0 ms.

    (114 row(s) affected)

    Table 'stable_vc'. Scan count 1, logical reads 3, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

    Table 'ptable_vc'. Scan count 1, logical reads 3, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

    SQL Server Execution Times:

    CPU time = 0 ms, elapsed time = 66 ms.

    ---------------------------------------------

    SQL Server Execution Times:

    CPU time = 0 ms, elapsed time = 0 ms.

    The 66ms for the elapsed time on the second query wasn't always there.. most the time it also was 0ms or 1ms...

    Is that time given by the WAITs, probably IO, the 2nd query has?

    Thanks,

    Pedro



    If you need to work better, try working less...