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

Open
roji opened this Issue Dec 13, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@roji
Copy link
Member

roji commented Dec 13, 2018

Npgsql allows users to change type mappings, either by plugins or manually. Changes can be done at two levels:

  • The global type mapper (static NpgsqlConnection.GlobalTypeMapper). This holds for all connections
  • The connection-specific type mapper (non-static NpgsqlConnection.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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment