-
Notifications
You must be signed in to change notification settings - Fork 94
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
Performance improvements for SSMS query while trying to expand stored procedures #1923
Performance improvements for SSMS query while trying to expand stored procedures #1923
Conversation
Signed-off-by: Sumit Jaiswal <[email protected]>
where t.relkind = 'v' | ||
and (s.nspname = 'sys' or (nis.name is not null and ext.nspname is not null)) | ||
and has_schema_privilege(s.oid, 'USAGE') | ||
and has_table_privilege(quote_ident(s.nspname) ||'.'||quote_ident(t.relname), 'SELECT,INSERT,UPDATE,DELETE,TRUNCATE,TRIGGER') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we call has_table_privilege with t.oid. The string creation seems redundant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
and has_schema_privilege(s.oid, 'USAGE') | ||
and has_table_privilege(t.oid, 'SELECT,INSERT,UPDATE,DELETE,TRUNCATE,TRIGGER') | ||
|
||
union all | ||
-- details of user defined and system views |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets add comment on these additional unions on why they are needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
case | ||
when t.typname = 'trigger' | ||
then 'TR'::char(2) | ||
when p.proretset then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this valid for TSQL?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
64d91ac
into
babelfish-for-postgresql:BABEL_3_X_DEV
… procedures (babelfish-for-postgresql#1923) Currently, the SSMS query to expand stored procedures is found to be very slow (~ 6 hours for 1000 procedures). The bad performance is found to be majorly occurring from sys.all_objects view. So, the following modifications have been done to the sys.all_objects : Bad row estimation arising due to the is_ms_shipped column in sys.all_objects view. This change fixes it by pushing down the computation of is_ms_shipped column to the respective unions. Made the datatype of type and name column consistent and removed the outer CAST as we are already casting them in the respective UNIONs. Removed subqueries and replaced them with suitable JOINs for better query planning. Task: BABEL-4008 Signed-off-by: Sai Rohan Basa <[email protected]>
Description
Currently, the SSMS query to expand stored procedures is found to be very slow (~ 6 hours for 1000 procedures).
The bad performance is found to be majorly occuring from sys.all_objects view. So, the following modifications have been done to the sys.all_objects :
type
andname
column consistent and removed the outer CAST as we are already casting them in the respective UNIONs.Signed-off-by: Sai Rohan Basa [email protected]
Issues Resolved
BABEL-4008
Test Scenarios Covered
Use case based - Tests for sys.all_objects are already present in
sys_all_objects-vu-*
filesBoundary conditions - N/A
Arbitrary inputs - N/A
Negative test cases - N/A
Minor version upgrade tests - N/A
Major version upgrade tests - N/A
Performance tests - Evaluated the performance before and after making the changes. Here are the results for 1000 stored procedures.
Before : Execution time = ~ 9 mins , Query Plan
After : Execution time = ~ 17 secs , Query Plan
Tooling impact - N/A
Client tests - N/A
Check List
By submitting this pull request, I confirm that my contribution is under the terms of the Apache 2.0 and PostgreSQL licenses, and grant any person obtaining a copy of the contribution permission to relicense all or a portion of my contribution to the PostgreSQL License solely to contribute all or a portion of my contribution to the PostgreSQL open source project.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.