Skip to main content

NpgsqlCommand optimizations and usage tip


Hi, all!

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. :)

Comments

Anonymous said…
wow gold | world of warcraft gold | wow power leveling | Cheap WoW Gold | Cheapest WoW Gold | Buy Cheap WoW Gold | cheapest wow gold | Buy WoW Gold | sell wow gold | WoW Accounts | wow accounts for sale | Buy WoW Power Leveling | Wow Honor Leveling | WoW profession leveling | WoW Reputation Leveling | WoW CD Key | WOW EU Gold | Cheap WoW Gold | wow gold for sale | Cheap WoW Power Leveling | WoW EU Accounts | world of warcraft accounts for sale | WoW EU CD Key | Lineage 2 Adena | Buy L2 Adena | Lineage 2 Adena for sale | Lineage 2 Accounts | Lineage 2 Power Leveling | Lineage 2 CD Key | Warhammer gold | Buy Warhammer Gold | Warhammer US Gold | Warhammer Power leveling | Warhammer CD Key | Warhammer Accounts | Warhammer EU Gold | Buy Cheap Warhammer Gold | WAR EU Gold | Buy Warhammer Power Leveling | Warhammer Online Accounts | Warhammer EU CD key | Aion gold | fast delivery Aion Gold | Aion Accounts | Aion Power Leveling | Aion CD Key | runes of magic gold | cheap runes of magic gold | runes of magic accounts | runes of magic power leveling | runes of magic cd key | runes of magic online gold | buy runes of magic eu gold | wow cheats | rom power leveling | runes of magic eu accounts for sale | cheap runes of magic cd key | FFXI Gil | Cheap FFXI Gil | Final Fantasy XI Gil | FFXI Power Leveling | FFXI CD Key | LoTRO Gold | Cheap Lotro Gold | LoTRO US Gold | LoTRO Accounts | Lotro accounts for sale | LoTRO Power Leveling | LoTRO CD Key | LoTRO EU Gold | Lord of the Rings Gold | LoTRO EU Accounts | Lotro Leveling | Lord of the Rings CD Key | Age of Conan gold | AoC US Gold | Cheap AoC Gold | Age of Conan Accounts | Age of Conan Power Leveling | Age of Conan Crafting Leveling | Age of Conan CD Key | Age of Conan EU Gold | Age of Conan Gold For Sale | Age of Conan Leveling | Age of Conan Accounts For Sale | AoC CD Key | The Chronicles of Spellborn Gold | Chronicles of Spellborn Gold | Chronicles of Spellborn Accounts | Chronicles of Spellborn Power Leveling | Chronicles of Spellborn CD key | atlantica gold | buy atlantica gold | atlantica power leveling | atlantica cd key | darkfall gold | buy darkfall gold | darkfall accounts | darkfall power leveling | darkfall cd key | silkroad gold | silkroad online gold | cheap silkroad gold | silkroad power leveling | Maple Story Mesos | Buy Maplestory Mesos | Maple Story Power Leveling | EVE ISK | EVE Online ISK | Cheap EVE ISK | EVE Power Leveling | EVE CD Key | EverQuest 2 Platinum | EverQuest 2 Gold | EQ2 Gold | EverQuest 2 Accounts | EverQuest 2 Power Leveling | EverQuest 2 CD Key
Anonymous said…
I did not know how to get strong, someone told me that you must have last chaos gold. He gave me some lastchaos gold, he said that I could buy last chaos gold, but I did not have money, then I played it all my spare time. From then on, I got some lastchaos money, if I did not continue to play it, I can sell cheap lastchaos gold to anyone who want.Once I played 4story, I did not know how to get strong, someone told me that you must have 4story Luna. He gave me some 4story Gold, he said that I could buy 4story Luna, but I did not have money, then I played it all my spare time. From then on, I got some 4story money, if I did not continue to play it, I can sell cheap 4story Luna to anyone who want.
Anonymous said…
Making Sho Online Mun is the old question : Honestly there is no fast way to make lots of Sho Mun . Sadly enough a lot of the people that all of a sudden come to with millions of Sho Online gold almost overnight probably duped . Although there are a lot of ways to make lots of Sho gold here I will tell you all of the ways that I know and what I do to buy Sho Online gold.

As a new player , you may need some game guides or information to enhance yourself.
angels gold is one of the hardest theme for every class at the beginning . You must have a good way to manage your angels online gold.If yor are a lucky guy ,you can earn so many buy angels goldby yourself.If you need , you cancheap angels online goldat our website . Go to the related page and check the detailed information . Once you have any question , you can connect our customer service at any time .
Ericwipe287 said…
I also have same slow performing problem Thanks for giving the solution. Keep it up!

dentists edinburgh

Popular posts from this blog

UUID datatype and COPY IN/OUT support added to cvs

Hi all! It was just added support to uuid datatype in cvs head. This type will be available in next Postgresql release 8.3. Thanks to David Bachmann for his patch! You can get more info about this patch in this mailing list post . Also was added support for copy in and copy out operations. Now, users can provide streams which can be copied directly to and from Postgresql tables! Thanks to Kalle Hallivuori for providing a patch! Thanks to Truviso for giving support to Kalle. More info about that including a demo and ready to use compiled Npgsql.dll versions can be found here . That's it! As soon as we get more features added, I will post info about them here. Stay tuned! :)

Npgsql Tips: Using " in (...)" queries with parameters list and "any" operator

Hi, all! We have received some users questions about how to send a list of values to be used in queries using the "in" operator. Something like: select foo, bar from table where foo in (blah1, blah2, blah3); Npgsql supports array-like parameter values and the first idea to have this working would try to use it directly: NpgsqlCommand command = new NpgsqlCommand("select * from tablee where field_serial in (:parameterlist)", conn); ArrayList l = new ArrayList(); l.Add(5); l.Add(6); command.Parameters.Add(new NpgsqlParameter("parameterlist", NpgsqlDbType.Array | NpgsqlDbType.Integer)); command.Parameters[0].Value = l.ToArray(); NpgsqlDataReader dr = command.ExecuteReader(); but unfortunately this won't work as expected. Npgsql will send a query like this: select * from tablee where field_serial in ((array[5,6])::int4[]) And Postgresql will complain with the followin...

Using Entity Framework 6 with Npgsql 2.1.0

UPDATE (2014-05-19): Marek Beneš noticed a problem in the default connection factory config. It is fixed now. Thanks, Marek! UPDATE (2014-02-20): I created a new post explaining how to get Npgsql 2.1.0. Although this post is about EF 6, I'd like to talk about our current situation to support both EF 6 and EF4.x which explain why there are some subtle changes between EF 4.x and EF 6.x App.config settings.  Support for EF versions 4.x and 6.x Sometime after we started to work on Npgsql 2.1.0, we started to add code to support EF6 and decided to reorganize our Entity Framework support code. Shay created a pull request to organize this change and isolate the EF code out of core Npgsql code. The result was the creation of two separated assemblies: Npgsql.EntityFramework.dll for EF6 and above; Npgsql.EntityFrameworkLegacy.dll for EF4.x. Only when using Npgsql with EF6 you will need to reference Npgsql.EntityFramework.dll assembly. This is needed because the EF ...