-
Notifications
You must be signed in to change notification settings - Fork 818
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
Speed up connection-specific mapping changes #2263
Comments
Another idea: if a global type mapping exists, and then the same mapping is done on a specific connection, simply ignore that entirely. See npgsql/efcore.pg#895 (comment). |
Less important now that the NodaTime plugin supports the BCL types (thanks @davidroth) |
Note: this was considerably improved by implementing lazy type handler binding (#3816). Resetting the type mapper now simply involves reverting to the global type mappings (very light), and clearing all existing type handler bindings. Since type handlers are now lazy, we no longer need to eagerly rebind everything. While theoretically we could improve things further (i.e. really track what changes were done on the connector type mapper and only revert those), there seems like there's really little value there at this point. |
Npgsql allows users to change type mappings, either by plugins or manually. Changes can be done at two levels:
NpgsqlConnection.GlobalTypeMapper
). This holds for all connectionsNpgsqlConnection.TypeMapper
).Changes to the connection-specific type mapper need to be restricted to the lifetime of the connection. That is, when a connection is returned to the pool, all changes must be reset, otherwise they will leak once the physical connection is returned again.
The current method for handling this checking whether any changes were done, and if so, disposing the entire type mapper and rebuilding mappings from scratch. This is a pretty heavy process that makes connection-based type mapping not very suitable for high-perf scenarios.
Instead, we could setup a sort of "undo list", tracking which mappings were changed and what needs to be done to reset them back.
The text was updated successfully, but these errors were encountered: