New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sp_BlitzCache add check for table variable use #422
Comments
It would be easy enough to identify table names beginning with '@' in execution plans, but physical tables can also lead with them. There's nothing explicit in an execution plan that differentiates between the two that I know of. At best we'd be guessing. Here's some repro code attached. (BGO: updated, switched to attached file because Github is stripping parts of it out.) |
I couldn't get this line to work: CREATE TABLE @craptable The only way I could get it to work was to frame it in brackets like this: CREATE TABLE [@craptable] Which I thought I'd be able to catch because typical table variables aren't framed in square brackets, but the diabolical engine is adding the brackets behind me even when I don't use them:
|
Yeah. I'm totally down to add it as something to look closer at in warnings, since physical tables that start with @ are pretty rare. The real benefit would be if we could also warn when estimates are skewed because of them, but of course cached plans don't give you actual vs estimated rows. |
During a SQL Performance Tuning class today with Brent, we were discussing the horrible performance of Table variables in SQL queries.
I would like to see the addition of functionality for the identification of queries that are using table variables in sp_BlitzCache to help in identifying these issues.
The text was updated successfully, but these errors were encountered: