Query with high lob logical reads / read-ahead reads

  • Hi

    I have a table with a column of image data type. Our application fires queries at this table, retrieving the data in this column only. The queries are efficient, using the clustered index in the WHERE clause. The table contains approx 6 million rows.

    With SET STATISTICS IO ON and SET STATISTICS TIME ON, I am seeing some varying performance depending on the fileID specified in the WHERE clause. The execution times vary, lob logical reads vary, and lob read-ahead reads vary. Although logical reads remain consistent.

    For example -

    --Query 1.)

    SELECT fileData FROM Files WHERE fileId = 6491281;

    Table 'Files'. Scan count 0, logical reads 3, physical reads 0, read-ahead reads 0, lob logical reads 4876, lob physical reads 0, lob read-ahead reads 2082.

    (1 row(s) affected)

    SQL Server Execution Times:

    CPU time = 32 ms, elapsed time = 1453 ms.

    --Query 2.)

    SELECT fileData FROM Files WHERE fileId = 6491868;

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

    (1 row(s) affected)

    SQL Server Execution Times:

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

    Has anyone ever seen this before or have any ideas why this might be?

    Would be really interested to know

    Thanks

  • Can you correlate the size of the image you're retrieving in query 1 to the number of lob reads, and the same for query 2?

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

  • Ok, so it looks like the size of the image being returned could be the issue.

    Looking into it, query 1 (with high lob logical reads) is actually retrieving a 6MB .mp4 file. Whereas Query 2 is getting a 1KB .xsl file..

    So the larger the physical file, the more image pages are read.

    Makes sense!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply