-
Notifications
You must be signed in to change notification settings - Fork 66
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
Optimized pgstat_init_function_usage/pg_newlocale_from_collation #188
Optimized pgstat_init_function_usage/pg_newlocale_from_collation #188
Conversation
…ion in creating index Signed-off-by: Parikshit Sarode <[email protected]>
@@ -40,8 +40,6 @@ int pgstat_track_functions = TRACK_FUNC_OFF; | |||
*/ | |||
static instr_time total_func_time; | |||
|
|||
pre_function_call_hook_type pre_function_call_hook = NULL; |
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.
We should not delete this hook definition, as it's a community PG code
src/backend/utils/adt/pg_locale.c
Outdated
@@ -1534,6 +1537,11 @@ pg_newlocale_from_collation(Oid collid) | |||
} | |||
|
|||
cache_entry = lookup_collation_cache(collid, false); | |||
|
|||
if (prev_cache && prev_cache->collid == collid) |
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.
Should wrap those code into a hook, and put the impl into babel code
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.
Here caching the very previous call using global pointer to avoid hash search. Creating a hook for this may be unnecessary
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.
We should try our best to make minimal change on PG side
src/backend/utils/adt/pg_locale.c
Outdated
} | ||
|
||
prev_cache->collid = cache_entry->collid; | ||
prev_cache->locale = cache_entry->locale; |
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.
We should move this part into babel specific too
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.
LGTM
Signed-off-by: Parikshit Sarode <[email protected]>
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.
LGTM
c7572cd
into
babelfish-for-postgresql:BABEL_3_X_DEV__PG_15_X
…elfish-for-postgresql#188) * Optimize pgstat_init_function_usage/pg_newlocale_from_collation function in creating index Signed-off-by: Parikshit Sarode <[email protected]> Task: BABEL-4300
…elfish-for-postgresql#188) * Optimize pgstat_init_function_usage/pg_newlocale_from_collation function in creating index Signed-off-by: Parikshit Sarode <[email protected]> Task: BABEL-4300
Description
In per row execution, when we call func like varncmp or varcmp inside fmgr_security_definer, it'll go through pgstat_init_function_usage in pg_stat_statements and pgstat_init_function_usage did a searchcache everytime when the function is called, this call is avoided in this update. Optimized both the functions by reducing system cache search every time by storing the previous cached values in pgstat_init_function_usage and pg_newlocale_from_collation.
Query execution time reduction is noticed after optimisation on varchar index.
Singned-off-by: Parikshit Sarode [email protected]
Issues Resolved
Optimised function pgstat_init_function_usage and pg_newlocale_from_collation by reducing the SearchSysCache1 calls.
Results
On database with 50000 entries including columns of datatypes -int, varchar, date, money , following results were obtained:
BABEL-4300
Check List
By submitting this pull request, I confirm that my contribution is under the terms of the PostgreSQL license, 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.