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
Introduce optional global TypeInfoCache #3200
base: master
Are you sure you want to change the base?
Introduce optional global TypeInfoCache #3200
Conversation
In the current implementation, `TypeInfoCache` is a per-connection cache. This means, over time, that the same type information is retrieved from the database copious times. For some DB systems, this has a negative cost/performance impact. Introduce an optional global `TypeInfoCache`. This is useful for cases where a single DB system is used in Production for all connections and there's no need for each connection to re-retrieve type info. - Extract the storage portion of `TypeInfoCache` into a new class, `TypeInfoCacheStorage` - Add new property, `GLOBAL_TYPE_INFO_CACHE` to enable a global cache - When enabled, the constant `TypeInfoCacheStorage GLOBAL_INSTANCE` is always used. Over the course of running a Production instance, this global cache should not need to query the database for type info.
829e5c8
to
e4a9de8
Compare
Thank you for the PR, however, I am leaning towards a different implementation:
WDYT? |
@vlsi we'd be happy with any solution that solves the issue for us. We're forking internally for now as it's become a big problem (note we use CRDB). Let me know if I can help in any way. |
@vlsi Note that memory consumption is not a concern for us here. The issue is the cost of repeatedly retrieving the type information. Would your solution avoid fetching the same information multiple times across connections? |
Ultimately, I would like to hard-code well-known pg catalog entries for the current DB versions, so query catalog only in case we face an unknown type. WDYT? |
I don't see another way to do this. So yes. |
It might be useful to have something like "global backend unique ID" returned on connect.
Currently, as a workaround we could assume |
Interesting. Something else we can ask for in the protocol changes
|
That is effectively what I proposed in #1980. Though that pr also addressed how the shared timer is used/managed. |
In the current implementation,
TypeInfoCache
is a per-connection cache. This means, over time, that the same type information is retrieved from the database copious times. For some DB systems, this has a negative cost/performance impact.Introduce an optional global
TypeInfoCache
. This is useful for cases where a single DB system is used in Production for all connections and there's no need for each connection to re-retrieve type info.TypeInfoCache
into a new class,TypeInfoCacheStorage
GLOBAL_TYPE_INFO_CACHE
to enable a global cacheTypeInfoCacheStorage GLOBAL_INSTANCE
is always used. Over the course of running a Production instance, this global cache should not need to query the database for type info.All Submissions:
Looks like there are a few PRs dealing with
TypeInfoCache
but this is different than those AFAICT.New Feature Submissions:
./gradlew styleCheck
pass ?Changes to Existing Features:
Does this break existing behaviour? If so please explain.
No
Have you added an explanation of what your changes do and why you'd like us to include them?
Yes
Have you written new tests for your core changes, as applicable?
Yes (though more thorough testing might be needed if you want)
Have you successfully run tests with your changes locally?
Yes