Skip to content
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

Perf: Investigate and optimize performance of Post-import Best Practices rules query execution #213

Closed
PiJoCoder opened this issue Jan 14, 2023 · 2 comments
Assignees
Labels
wave 2 - complete consider this issue for next wave of fixes

Comments

@PiJoCoder
Copy link
Collaborator

No description provided.

@PiJoCoder PiJoCoder added the wave 2 - complete consider this issue for next wave of fixes label Jan 14, 2023
@PiJoCoder PiJoCoder self-assigned this Jan 14, 2023
@PiJoCoder
Copy link
Collaborator Author

PiJoCoder commented Jan 14, 2023

Discovered that this query can be very long if tblTopSqlPlan is populated with a large query plans. The query is processing XML in memory. The tblTopSqlPlan contains only 5 rows based on PSSDIAG collection but again if the plans are large, it is expensive to process the XML. In my test with a data set, it took slightly over 3 minutes to run this query.

set QUOTED_IDENTIFIER on; 
WITH XMLNAMESPACES ('http://schemas.microsoft.com/sqlserver/2004/07/showplan' AS sp)  
select distinct  stmt.stmt_details.value ('@Database', 'varchar(max)') 'Database' ,  stmt.stmt_details.value ('@Schema', 'varchar(max)') 'Schema' ,  
 stmt.stmt_details.value ('@Table', 'varchar(max)') 'table'   --into tblObjectsUsedByTopPlans

 from 
 (  select cast(FileContent as xml) sqlplan from tblTopSqlPlan) as p       cross apply sqlplan.nodes('//sp:Object') as stmt (stmt_details) 

@PiJoCoder
Copy link
Collaborator Author

PiJoCoder added a commit that referenced this issue Jan 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wave 2 - complete consider this issue for next wave of fixes
Projects
None yet
Development

No branches or pull requests

1 participant