-
Notifications
You must be signed in to change notification settings - Fork 67
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
Changes from 9 commits
1f522ae
3cc2bb3
1b59f6c
2e877b2
384f016
c29233d
feeff30
23719fb
9def02e
60b1145
ffa60e9
4e029e2
609b5af
b765f9e
ac8856e
1218852
72b05fd
ec3dd2b
442ce28
c3c6e17
2146b8b
90bfd42
c4ed2e7
85ad106
ab17144
042adee
792febd
282ccfd
064b3b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1517,6 +1517,9 @@ report_newlocale_failure(const char *localename) | |
* might only need one of them. Since this is called only once per session, | ||
* it shouldn't cost much. | ||
*/ | ||
|
||
collation_cache_entry *prev_cache = NULL; | ||
|
||
pg_locale_t | ||
pg_newlocale_from_collation(Oid collid) | ||
{ | ||
|
@@ -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 commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. We should try our best to make minimal change on PG side |
||
{ | ||
return prev_cache->locale; | ||
} | ||
|
||
if (cache_entry->locale == 0) | ||
{ | ||
|
@@ -1676,6 +1684,21 @@ pg_newlocale_from_collation(Oid collid) | |
cache_entry->locale = resultp; | ||
} | ||
|
||
if(prev_cache) | ||
{ | ||
pfree(prev_cache); | ||
} | ||
|
||
prev_cache = (collation_cache_entry *) MemoryContextAlloc(CacheMemoryContext, sizeof(collation_cache_entry)); | ||
|
||
if(prev_cache == NULL) | ||
{ | ||
ereport(ERROR, (errmsg("Memory allocation failed"))); | ||
} | ||
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. We should move this part into babel specific too |
||
|
||
return 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 not delete this hook definition, as it's a community PG code