Some days ago, I fixed a slow performance problem with Npgsql when calling functions. The problem was that Npgsql was doing a lot of expensive checks (in fact, 3) to verify parameter information and return type. The solution was to cache those checks so that new calls to the same function don't need to pass through the same checks again.
In order to not have problems with outdated caches and etc and after talking to Josh on gmail, I decided to make the cache local and it would be invalidated as soon as the command text is changed.
This semantics lead me to write this blog to share the idea that you can get a big performance improvement if you "cache" your NpgsqlCommands which will be used with function calls. This way, instead of creating and releasing the command object after its usage, you can create all your NpgsqlCommand objects associated to function calls and reuse them as needed. This way you pay for the costly checks only once.
I hope this tip can help people to get some performance gains from this fix. :)