IsDBNull() alternative
Saw Frans Bouma posted the following in the comments of one ASP.NET webloggers. I make pretty frequent use of IsDBNull() so its a good tip to know.
“What's often forgotten though is that dr.IsDBNull() is very very very slow. Better do:
bool isNull = (dr[ordinal]==System.DBNull.Value);
Saves 20% of speed”
Legacy Comments
Lavos
2004-04-11 |
re: IsDBNull() alternative Color me lazy, but could you provide a direct perma-link to the comment? I'm particularly curious if he gave any reasonings behind why he said it was slower, and in what way it's slower. I'm mainly curious because it reminds me of the reasons behind using multiple string concats/method calls vs something that uses a format string. The standard suggestion is to use the format string because it's more maintanable, and not likely to be your performance problem despite being much much slower. |
Justin
2004-04-12 |
re: IsDBNull() alternative Lavos, Here is the link... http://weblogs.asp.net/justin_rogers/archive/2004/04/11/111151.aspx |
Frans Bouma
2004-04-12 |
re: IsDBNull() alternative Lavos: I didn't know it was so slow until I profiled my code and it turned out that it was incredibly slow. Apparently the routine does a lot behind the scenes or something. So I changed the IsDBNull call to the one mentioned in the blog and the routine became significant faster. In a loop which is ran a lot (a 100 row, 10 column wide resultset, that's 1000 times IsDBNull) it can be significant. |
Justin Rogers
2004-04-13 |
re: IsDBNull() alternative The actual framework issue behind IsDBNull being slow. http://weblogs.asp.net/justin_rogers/archive/2004/04/13/112100.aspx |
test
2005-06-09 |
re: IsDBNull() alternative test |
diran
2005-10-03 |
re: IsDBNull() alternative hhhhhhhhh hhhhhhhhhhhhhhhhhhhhhhh hhhhhhhhhhhhhhhhhhhhhhh hhhhhhhh hhhhhh h h h h hh h h hh h |
erer
2005-10-15 |
re: IsDBNull() alternative weblogs.sqlteam.com/justinb |
call center India
2006-06-07 |
call center India For outsourcing voice, chat, email or back-office support, visit the website http://callcenter.ramshyam.com |