Timeline for Creating ADODB Parameters on the fly
Current License: CC BY-SA 3.0
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Apr 10, 2014 at 3:24 | vote | accept | Mathieu Guindon | ||
| Apr 5, 2014 at 3:38 | comment | added | Hogan | Very good point, the performance effect is basically zero for all use cases. | |
| Apr 5, 2014 at 3:24 | comment | added | Mathieu Guindon |
Indeed, I just benchmarked adding 10000 items to a Collection, direct calls: 0-15 ticks, indirect calls: 16-94 ticks. With 100000 items I see a bigger difference: 47 ticks for direct calls vs 180 ticks for indirect calls. I think it's premature optimization to presume there's a massive performance hit with CallByName, the number of parameters of any possible query is way below anything that will make a significant difference in performance.
|
|
| Apr 5, 2014 at 3:14 | comment | added | Hogan |
I see that they replace the Select but the "dynamically named call" is going to be slow so I don't see an advantage to replacing it in this way just a dis-advantage. To solve the edge case a cast will work there like ToParameter(CByte(aParm),... vs ToParameter(CShort(aParm),...
|
|
| Apr 5, 2014 at 3:08 | comment | added | Mathieu Guindon |
+1 for the casting which is effectively redundant. However the functions specifically fulfill the purpose of replacing a Select..Case block like you're suggesting. Extracting that AdoValueConverter type also allows extending the type with further refinements, such as configurable type mappings; sometimes a Byte value will need to be passed as a smallint, other times as an int - converting a value to an ADODB.Parameter can become quite complex with tons of edge cases (how about a string that contains a GUID, do I pass it as a String or a GUID?), I find it's a concern of its own.
|
|
| Apr 5, 2014 at 2:59 | history | answered | Hogan | CC BY-SA 3.0 |