Options

Tab History extremely slow previewing query with huge IN clause containing casts

daveg717daveg717 Posts: 1 New member
While investigating a slow Entity Framework query, I pasted a query into SSMS with a WHERE statement containing a huge IN clause.  The IN clause had a little over 13,917 integers in it, and each of them was being cast to a bigint as follows:
WHERE ID IN (cast(1111111 as bigint), cast(2222222 as bigint), etc )
Lovely query, ain't it? :{  I resolved my EF issue so it doesn't do that anymore, but after closing this tab in SSMS and then later opening Tab History, the TH window would freeze for around 45 seconds as it tried to load the preview for this query.  I did a little experimenting with the query and found that removing the cast statements eliminates the performance issue with TH.  I was wondering if someone could take a look, I've attached a sample file that demonstrates the issue. I'm using SSMS 18.9.1 with SQL Prompt 10.6.12.20269 running Win10 20H2 on an i7-8850H 32GB RAM.

Answers

Sign In or Register to comment.