May 2, 2025 at 3:21 pm
Have a table with varbinary(8000) column.
When carrying out a select and including this column the query takes twice as long, when I remove it the query takes half time.
Any suggestions? The column isn't included in the join or where clause
May 3, 2025 at 4:10 pm
Thanks for posting your issue and hopefully someone will answer soon.
This is an automated bump to increase visibility of your question.
May 4, 2025 at 3:42 am
Maybe this hints at what's going on?
https://blog.greglow.com/2019/02/26/sql-text-vs-varcharmax-in-row-vs-out-of-row-storage/
It might be that the varbinary(8000) is stored outside the row of your table, so when you do not include that column in your query, it executes quickly, because the engine can just scan a segment of memory. When you request the varbinary column, the engine has to find where that is stored, which is not in the contiguous block of data. ... I think that's what the article is saying.
May 4, 2025 at 4:26 pm
The varbinary column may contain large data such as BLOBs or images, which can take a long time to read. Try using data compression -it might help!
May 4, 2025 at 5:04 pm
Sorry forgot to mentioned the table has columnstore index with partitions enabled.
May 5, 2025 at 11:54 am
My suspicion is that it's not so much that the query is taking longer to execute, as it is taking more time to send the results to (I'm presuming) SSMS and get them displayed.
One thing you could look to try to see if this is potentially the issue, check your wait stats for ASYNC_NETWORK_IO, once when you query the data without the varbinary, and once with. Ideally, do this during a quiet time for the app, and if you really want to make it easier to see the numbers, run "DBCC SQLPERF ('sys.dm_os_wait_stats', CLEAR);" before each test.
Or, if you're handy with Extended Events you can capture the info that way.
But, and again presuming I'm on the right track here, your columnstore index and partitioning aren't going to make a difference.
May 6, 2025 at 8:08 am
I don't see ASYNC_NETWORK_IO waits when running the query including the column that is varbinary. There was just PAGEIOLATCH_SH wait
Just some stats
--4.33min with varbinary column
--28 sec without varbinary column
May 6, 2025 at 12:02 pm
So presuming it's a spike in PAGEIOLATCH_SH when the query runs with the varbinary, that's an indicator that the problem *could* be the storage on the server.
Can you give some info on the specs of the server? Especially the type of disk (hard disk with spinning platters, SSD, virtual server, NVMe) and the RAM in the server? Not going to say "throw hardware at it," but that might be the road to go down.
And one more question, is this a recent problem, or has it always been this way? If it's recent, has something changed, either in the database or the server itself?
May 7, 2025 at 2:35 pm
Its on AWS.
8 CPU and 64 RAM
I need to include the varbinary column in the query.
It is a new problem, today the query is taking 59 seconds
May 8, 2025 at 12:00 pm
So I will note, storage could still be a problem, we're in Azure and a few of our apps had unacceptable database performance until we bumped up the storage tier the database files were on.
And to be sure I'm understanding your last post right, yesterday the time for the query that was taking 4.5 minutes took just shy of 1 minute?
Something else to look into, is there any sort of anti-virus / anti-malware on the server that might be scanning the database files? MS does recommend configuring any such AV to not "live" scan mdf / ndf / ldf (Configure antivirus software to work with SQL Server) although I would expect this to impact any use of the database, not just querying and retrieving a varbinary.
May 8, 2025 at 12:48 pm
Yes was taking less time but today it back up around the same time. For me it seems like a storage issue, I don't think there is anything additional that can be done on the query side.
May 15, 2025 at 7:41 pm
I notice you didnt post the query. Are you doing any SORT operations anywhere ?
----------------------------------------------------
May 16, 2025 at 1:00 am
To be clear... your query without including the VARBINARY might be returning 20 bytes per row and then you can't understand why it takes about twice as long to return about 400 times that amount of data for each row?
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 13 posts - 1 through 13 (of 13 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy