• josh 92884 (10/21/2013)


    First post here so hope I don't come of as too newb with this.

    I have a table on a MSSQL 2000 with about 4700 rows.

    My query:

    SELECT * FROM Product with (nolock);

    only comes back with about 250 rows, sometimes slightly less or more. This query also takes awhile to complete. Longer than these:

    SELECT colname FROM Product with (nolock);

    SELECT * FROM Product;

    which come back with the correct number of records.

    I'm a little mystified. What is it about the combination of * and NOLOCK that causes this?

    Nothing unusual stands out to me about the table design. It is a clustered index with a few non-clustered indexes on non-key columns. DBCC SHOWCONTIG(Product) looks reasonable.

    Anyone have any ideas? or next steps to investigate?

    I've never seen WITH(NOLOCK) cause such a large disparity in the number of rows like that before. Any clues in the execution plan?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)