-
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
Automatically run ANALYZE after babelfish extension create/upgrade #1922
Automatically run ANALYZE after babelfish extension create/upgrade #1922
Conversation
Signed-off-by: Sumit Jaiswal <[email protected]>
Signed-off-by: Sumit Jaiswal <[email protected]>
Signed-off-by: Sumit Jaiswal <[email protected]>
Signed-off-by: Sumit Jaiswal <[email protected]>
Signed-off-by: Sumit Jaiswal <[email protected]>
Signed-off-by: Sumit Jaiswal <[email protected]>
Signed-off-by: Sumit Jaiswal <[email protected]>
Signed-off-by: Sumit Jaiswal <[email protected]>
Signed-off-by: Sumit Jaiswal <[email protected]>
EXECUTE format('ANALYZE %I.%I', schema_name, babelfish_catalog.name); | ||
EXCEPTION WHEN OTHERS THEN | ||
GET STACKED DIAGNOSTICS error_msg = MESSAGE_TEXT; | ||
RAISE WARNING 'ANALYZE for babelfish catalog %.% failed with error: %s', schema_name, babelfish_catalog.name, error_msg; |
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.
When we have this warning in the upgrade, what's our action item ?
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.
Warning will help us to debug any performance issue after upgrade due the failure. I will add the same in Jira also.
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.
how will it lead to action on customer or our side? A warning will go to upgrade scripts and might be lost if no one takes a look.
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, warning will not lead to any action but it will be helpful for any performance issue observed just after the upgrade and logs are present.
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.
Let us track this item via a Jira. Talk to Sharu about this. We should consider how we track successful MVUs and corresponding logs in long term to resolve issues down the line.
contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--3.3.0--3.4.0.sql
Show resolved
Hide resolved
EXECUTE format('ANALYZE %I.%I', schema_name, babelfish_catalog.name); | ||
EXCEPTION WHEN OTHERS THEN | ||
GET STACKED DIAGNOSTICS error_msg = MESSAGE_TEXT; | ||
RAISE WARNING 'ANALYZE for babelfish catalog %.% failed with error: %s', schema_name, babelfish_catalog.name, error_msg; |
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.
how will it lead to action on customer or our side? A warning will go to upgrade scripts and might be lost if no one takes a look.
Signed-off-by: Sumit Jaiswal <[email protected]>
b5fb8d0
… during source latest to target latest Signed-off-by: Sumit Jaiswal <[email protected]>
Signed-off-by: Sumit Jaiswal <[email protected]>
Signed-off-by: Sumit Jaiswal <[email protected]>
test/JDBC/input/AUTO_ANALYZE-before-15-5-or-14-10-vu-prepare.sql
Outdated
Show resolved
Hide resolved
Signed-off-by: Sumit Jaiswal <[email protected]>
Signed-off-by: Sumit Jaiswal <[email protected]>
354feb0
into
babelfish-for-postgresql:BABEL_3_X_DEV
…abelfish-for-postgresql#1922) Earlier, when having less than 50 schemas on the fresh instance causes the poor performance for problematic query when having large number of objects in database. In case of less than 50 schemas, sys.babelfish_namespace_ext catalog which stores the name of schema will have less than 50 rows which means autovacuum ANALYZE has never been run by PostgreSQL autovacuum daemon as the number of inserted rows doesn't exceeds the threshold criteria. Since the sys.babelfish_namespace_ext catalog has never been analyzed it leads bad query planning for large query. This commit add changes to automatically run ANALYZE after babelfish extension create/upgrade for all babelfish catalogs to avoid such issues in future. Issues Resolved Task: BABEL-4487 Signed-off-by: Sumit Jaiswal [email protected]
…1922) (#1958) * Automatically run ANALYZE after babelfish extension create/upgrade (#1922) Earlier, when having less than 50 schemas on the fresh instance causes the poor performance for problematic query when having large number of objects in database. In case of less than 50 schemas, sys.babelfish_namespace_ext catalog which stores the name of schema will have less than 50 rows which means autovacuum ANALYZE has never been run by PostgreSQL autovacuum daemon as the number of inserted rows doesn't exceeds the threshold criteria. Since the sys.babelfish_namespace_ext catalog has never been analyzed it leads bad query planning for large query. This commit add changes to automatically run ANALYZE after babelfish extension create/upgrade for all babelfish catalogs to avoid such issues in future. Issues Resolved Task: BABEL-4487 Signed-off-by: Sumit Jaiswal <[email protected]>
Description
Earlier, when having less than 50 schemas on the fresh instance causes the poor performance for problematic query when having large number of objects in database. In case of less than 50 schemas, sys.babelfish_namespace_ext catalog which stores the name of schema will have less than 50 rows which means autovacuum ANALYZE has never been run by PostgreSQL autovacuum daemon as the number of inserted rows doesn't exceeds the threshold criteria. Since the sys.babelfish_namespace_ext catalog has never been analyzed it leads bad query planning for large query. This commit add changes to automatically run ANALYZE after babelfish extension create/upgrade for all babelfish catalogs to avoid such issues in future.
Signed-off-by: Sumit Jaiswal [email protected]
Issues Resolved
Task: BABEL-4487
Test Scenarios Covered
Performance tests
Execution time for Problematic query:
Before ANALYZE: 29 min query plan
After ANALYZE: 2 sec query plan
USE CASE BASED
Manually tested with creating table for which analyze will fail
Logs:
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.